Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pass query string parameter to UrlHelper.Action method in .net mvc

Tags:

asp.net-mvc

I have method like

 UrlHelper.Action("login", "Authentication", HttpContext.Current.Request.Url.Scheme);

I want to pass query string parameter like "referrer?" = pageName to this method. How can I do it?

like image 767
Vaidehi Hirani Avatar asked Jun 14 '16 10:06

Vaidehi Hirani


People also ask

How do you pass a model object in URL action?

You can consider passing each of the individual properties for your object using something like this : @Url. Action("Action","Controller", new { PropertyA = Model. PropertyA, PropertyB = Model.

What is action parameters in MVC?

Action Method Parameters are most important in MVC. If you want to handle post request in action methods; MVC framework provided types of Action Methods Parameters. Action Method Parameters. We can organize the action methods for GET and POST requests separately.


1 Answers

You just have to decalre your parameter like this:

UrlHelper.Action("login", "Authentication", new { referrer = "Page Name" })

Then get the parameter in your Action:

Request.Params["referrer"]
like image 193
user3378165 Avatar answered Sep 30 '22 13:09

user3378165