Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7076273
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:16:42+00:00 2026-05-28T06:16:42+00:00

I am currently working with a generic handler in asp.net. I believe it is

  • 0

I am currently working with a generic handler in asp.net. I believe it is currently in a sort of “listening” state awaiting POSTs. I am expecting a POST with a filename Header, and once received the handler will deal with downloading the file. My handler code is below:

Sub ProcessRequest(Byval context as HttpContext) Implements IHttpHanlder.ProcessRequest

If context.Request.HttpMethod() = "POST" Then
Dim Reader as New StreamReader(context.Request.InputStream)
Dim contents as String = reader.ReadtoEnd()

Dim filename as String = context.Request.Headers(("filename"))
System.IO.File.Writealltext(ConfigurationManager.AppSettings("outputdirectory"), contents)
Else
context.Response.ContentType = "text/plain"
context.Response.ContentType("Handler is alive")
End If

End Sub

I would like to replicate a post and see if it takes it in successfully. Would it be possible to generate and send this post from another program on my machine. I have attempted a few tutorials including this one

SO – POST Tutorial

I feel that I have gotten the closest using this code(from previous link)

Using wc as New System.Net.WebClient
wc.UploadFile("http://localhost:Port/local/of/handler", "C:\local\of\file.txt")
End Using

I am receiving a 500 error from the remote server. Would this be an issue with the handlers code? Or am I just not making the right type of POST?

When messing around with wc.Headers()/Darin’s suggestion I still get a 500 error. The exception is below.

System.Net.WebException: The remote server returned an error: (500) Internal Server Error
at System.Net.HttpWebRequest.GetResponse()
at System.Net.Webclient.GetWebResponse(WebRequest request)
at System.Net.WebClient.WebClientWriteStream.Dispose(Boolean disposing)
at System.IO.Stream.Close()
at System.IO.Stream.Dispose()
at TestPOSTGETEXE.Form1.Button4_Click(Object sender, EventArgs e) in C:\blah\blah\..\..\..\
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T06:16:43+00:00Added an answer on May 28, 2026 at 6:16 am

    Try like this:

    Using wc As New System.Net.WebClient
        wc.Headers("filename") = "file.txt"
        Using writer = wc.OpenWrite("http://localhost:Port/local/of/handler")
            Dim file = System.IO.File.ReadAllBytes("C:\local\of\file.txt")
            writer.Write(file, 0, file.Length)
        End Using
    End Using
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently working with .Net 2.0 and have an interface whose generic type
I'm currently working on an ASP.NET MVC project using NHibernate and I need to
I am creating an ASP.NET MVC 3 e-commerce website and I am currently working
Am currently working on an application that requires users to submit posts and comments
I'm currently working on a project in which I'd like to define a generic
I'm currently working in .NET 2.0 Visual Basic. The current project is an Active
I am currently working in Ubuntu9.10 - c++. I need to define an generic
I'm currently working on a generic collection class and I'd like to create a
Currently working in the deployment of an OFBiz based ERP, we've come to the
Currently working on a VBScript to automate some of the dirty PST ingestion work

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.