I need to serialize some object into xml, which has string property "Url" - url of page returned by some action method (in asp.net mvc 3 app I want to implement custom rss).
I guess to call action method I just need to instantiate the controller which this method belongs to :)
MyController c = new MyContrroller();
c.MyActionMethod();
But how can I get the url of the page returned by this action method??
Edit 1: As the @SLaks answered we can use Url.Action()
to get action method url, but how can I pass this url to the xml file?? If I just assign the result of Url.Action()
to the link
it will display the string: MyController/MyAction.
Pages returned by action methods do not have URLs.
Instead, the action methods themselves have URLs that come from the routing engine.
You can get the URL to an action by calling Url.Action(actionName, controllerName)
.