Assuming that I'm talking about an ASP.NET MVC 3 application, the scenario is something like
- I browse to the URL
http://localhost:60088/Example?param1=test123
that returns a view - Next I click a button that triggers an Ajax call to the URL
http://localhost:60088/Example/DoSomethign
that returns a JSON string
So, my dilemma is that in the DoSomething
controller action I need to get the param1
parameter that was passed in the first step.
My first take is to do something like this:
public ActionResult DoSomething()
{
...
Uri baseUrl = this.Request.UrlReferrer;
// Somehow extract the parameter from baseUrl
...
}
But I'm not sure if that's a good idea at all...
Questions:
Is safe to assume that
this.Request.UrlReferrer
will always have the URL that was called in a non-callback way (even if I made several more callbaks after the_DoSomething_
first callback)?Is there a better way to accomplish waht I'm trying to do?