Friday, October 16, 2015

Genenrate full Url (absolute Url) using C# in ASP.NET MVC

A quick way to generate full Url (absolute Url) in ASP.NET MVC:

Url.Action("Details", "Product", new { id = p.ProductID}, Request.Url.Scheme)


If without id, simply use null in the parameter.

Url.Action("Details", "Product", null, Request.Url.Scheme)

No comments: