views:

73

answers:

2

Hello,

Is there a way to generate URL inside a controller? I want to do the following inside a controller instead of a view.

<% =Url.Action("Validate", "Home", New With {.ValidID = ID})%>

+5  A: 

Just remove the "Bee-stings."

Something like:

url = Url.Action("Validate", "Home", New With {.ValidID = ID})
John Gietzen
+1  A: 

Yes, as long as your controller inherits from Controller (which it must in order to work as an MVC controller), you can use the same syntax without the <%= %>.

Dim url = Url.Action("myAction", "myController", New With { ... })

alternatively if you reference the MVCContrib DLL, you will have access to strongly typed helpers, and be able to do something like:

Dim url = Url.Action(Of myController)(function(a) a.myAction(ID))

my VB coding days are dated, so forgive me if the syntax is a bit fudged

kmehta