0

This is similar to the SO question here..

How to generate a path/url from a Route in the Routes table?

..only this time I'd like to be able to build a url within one of my Model (partial) classes.

I'm defining a new property that will contain the text to be rendered within an rss feed, and want to insert urls (within anchor tags) in this text.

I found the UrlHelper.GenerateUrl method, but get unstuck once I get beyond passing in the appropriate RouteName, ActionName and ControllerName.

Community
  • 1
  • 1
marcusstarnes
  • 6,393
  • 14
  • 65
  • 112

1 Answers1

2

Generating urls in the model is actually a bad idea. I would recommend you generating the url in the controller and pass it to the model as parameter if necessary or use a HTML helper in the view which will do the job.

Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928