1

I'm working on a legacy ASP classic application. This application also supports an API, written in C# using Web API 2.

I'd like to add functionality to this API that will consume a request (as a resource - which will contain data need to satisfy a workflow), validate that request, and inside the API controller, generate a new request to an ASP page (the workflow is quiet complicated, so rather than re-write that logic, re-using the ASP page provides better business value).

Ideally I'd like to wait for the response inside the controller, and then pass back an Action Result (like a 204) to the consumer of the API.

The idea here is to hide the response of the ASP page, and return something simple to the consumer.

I know how to structure the URL somepage.asp?p1=help&p2=me, however I'm not sure how to create it as a request, execute it, and then consume the response within the API controller.

Is it even possible?

CraigRyan
  • 31
  • 4
  • Short Answer: Yes. Start by looking at the [`WinHttpRequest` object](https://msdn.microsoft.com/en-us/library/windows/desktop/aa384106%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396). [Here is an example](http://stackoverflow.com/a/37462944/692942) how to use the `WinHttpRequest` object. – user692942 Sep 19 '16 at 10:37
  • thanks @Lankymart. though what I'm looking to do is the other way around, I want to call an ASP page from my Api Controller. After doing a bit more research, I'm guessing using something like WebClient might work. Right? – CraigRyan Sep 19 '16 at 23:03

0 Answers0