I am new to ASP.NET MVC and trying to learn new things while playing around with the following scenario, but didn't get it working.
Actually, I am trying to maintain a constant value parameter in the url for every request. Something similar when we have a session value in the url, after using <sessionState cookieless="true"/>
in Web.config file and it starts showing session value in this format
http://localhost:49961/(S(swl0ancynhWw2103jxm4ydwf))/Customer/Home
But I am trying to have a persistent parameter appended at the end of url for every request, like following link
http://localhost:49961/Customer/Home?constantVal=12345
This parameter is assumed to remain in url, whether I am using any HttpGet
or HttpPost
method.
So far I have tried re-writing the url using Application_BeginRequest()
inside Global.asax.cs file in following way:
void Application_BeginRequest(object sender, EventArgs e)
{
// Suppose Request.FilePath = /Customer/Home/UploadFile
// Unable to use "?constantVal" as required
Context.RewritePath(Request.FilePath + "/12345");
}
Action Method:
public ActionResult UploadFile(string id = null)
{
return View();
}
In the above way, although I am able to get value for id = "12345" in UploadFile Action, but neither it is showing in the url anywhere or it also require every HttpGet
method to have a receiving id parameter.
It's always nice to do something crazy so that you can better understand a system. :)