4

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})%>

1
  • Cannot select both so selected the first one , thanks Commented Feb 4, 2010 at 15:32

2 Answers 2

6

Just remove the "Bee-stings."

Something like:

url = Url.Action("Validate", "Home", New With {.ValidID = ID})
Sign up to request clarification or add additional context in comments.

Comments

2

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.