Lostaunaum Lostaunaum - 1 year ago 82
C# Question

How to direct an .aspx response into a controller method

I am sending a request to a service which prompts a form. In my request I am sendint an XML object that looks like this:


The XML works fine and I get the desired response form. However my issue is that whenever i fill out the response and send the post request the redirect URL is this one:


this is the feed:

POST https://localhost:44300/efile/EPayment.aspx HTTP/1.1
Host: localhost:44300
Connection: keep-alive
Content-Length: 3349
Cache-Control: max-age=0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Origin: https://localhost:44300
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.125 Safari/537.36
Content-Type: application/x-www-form-urlencoded
Referer: https://localhost:44300/efile/GeneratingXMLFormRequest
Accept-Encoding: gzip, deflate
Accept-Language: es,en-US;q=0.8,en;q=0.6

A couple of questions:

1) How can I direct this POST request to a controller method within my Efile controller? Right now I am getting an error since I do not have a method called Epayment.aspx I tried creating a method called exactly this but that does not work properly.

2) Is it possible for the service to send the POST request to the Referer URL? That's the URL I provided in the XML however the service is using a different one and I am not 100% sure where is it getting that from.

Answer Source

Decorate your EPayment action with the ActionNameAttribute like so:

public class efileController : System.Web.Mvc.Controller {

    public ActionResult EPayment() {    
        // "EPayment" method name could be *any* name you wanted.  
        // The method name will never be exposed via the public API 
        // as long as you are using the ActionName attribute.
        return View();
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download