Question

I am writing an asp.net web application to talk to sage pay and make payments via their server to server method. At present my site collects user details and then sends a transaction registration HttpRequest to their server. Their server then responds to my request with some details and a redirect link. I check out the reponse object and then redirect to their payment page where the users payment details (card number etc) can be entered. Once the user has clicked confirm then sage will send a POST to a url of my choosing which I can then process and tell them whether to continue with the transaction or not.

What I am aiming to do is receive the POST from them, check the content and respond accordingly. I must then give them as part of my success or failure url which their site will send the user too on completion of the transaction. If I were sending a request first it would be easy but I am not. They just need an address to send the response to and then I must process it.

My question is this. How can I handle an HttpRequest (I assume this is what it will be?) in my web application?

Can I do this by telling them to respond to a generic handler? If I were to give them the url of my generic handler could I process the POST in there and then respond to them?

Was it helpful?

Solution

Can I do this by telling them to respond to a generic handler? If I were to give them the url of my generic handler could I process the POST in there and then respond to them?

The Generic Handler will work. You can handle the request parameters via context.Request.Params

Example:

public class Handler : IHttpHandler {

    public void ProcessRequest (HttpContext context) {

    string someparamreturned = context.Request.Params["somekey"];
    //etc.. do something
    }

    public bool IsReusable {
    get {
        return false;
    }

}

You don't really need a full-blown up page to handle this.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top