Here’s the method of the controller
public class FeedController : ControllerBase
{
public RssActionResult Rss()
{
//........
List<SyndicationItem> items = new List<SyndicationItem>();
var photosList = Facade.Photos.Get()
.Select(x =>
new SyndicationItem(
x.Title,
x.PreviewPath,
new Uri("http://site.com/"+CurrentLocale.CultureName+"/photos/show/" + x.ID + ".html"), x.ID.ToString(),
DateTime.UtcNow)
);
//........
return new RssActionResult() { Feed = feed };
}
}
How can I avoid the hardcoding of the Uri?
UPDATE
routes.MapRouteLowercase(
"Photos_Route",
"{culture}/photos/{action}/{id}.html",
new { controller = "photos", action = "show", culture = defaultCulture }
);
If the URI is a resource on your own site, and if you have a route defined for it, you can use something similar to this:
There are several overrides for the RouteUrl method.
Otherwise, if that URI is a resource on some other site, you can just store the URI format in web.config, and use string.Format(urlFormatFromWebConfig, x.ID) to generate the URL.
EDIT: More specific, now that you updated with your Route: