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,279
  • 12
  • 62
  • 108

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
  • 994,864
  • 265
  • 3,241
  • 2,902