We have a server application that loads into the IIS worker process. When we request a url from a browser, our application can see the current httpcontext but it is null when we use a tool that sends some upload requests using .net WebRrquest.Create method.
What we are trying to solve is tha开发者_开发技巧t when a request comes from our tool, we send some extra parameters in its headers so that our applicatin at the server end can understand that this request needs some special handling.
What should be the approach that we should follow?
Have you considered using SimpleWorkerRequest
See an example here
Is is an actuall http request, or is it spoofed inside the IIS process? I would recommend using HttpWebRequest (or simpler: WebClieny) so that your request is fully valid. You can still set headers etc.
At the simplest level:
using(var client = new WebClient()) {
// add headers etc
client.DownloadString(url);
}
精彩评论