Pass url string as parameter to mvc controller

I need to pass the full website url to my controller action, for example:

http://myweb/controller/action/http://blabla.com/dir2 

How to create a new route for transferring this parameter to action?

+4
source share
3 answers
 routes.MapRoute("Name", "{controller}/{action}/{*url}"); 

Additional Information:

+6
source

Pass it as a parameter.

 <%= Html.ActionLink( "Link", "MyAction", "MyController", new { url = "http://blah.com/blah" }, null ) %> 

Should create a link that looks like this:

 <a href='/MyController/MyAction?url=http://blah.com/blah'>Link</a> 

Your action will look like this:

 public ActionResult MyAction( string url ) { ... } 
+3
source

I agree that this could be a caching issue. If cache: false does not help, try to decorate your action (or controller) with this attribute: [OutputCacheAttribute(VaryByParam = "*", Duration = 0, NoStore = true)]

0
source

All Articles