in asp.net-mvc, how can i build up URLs in controller
if my current controller, my URL is:
http://test.mysite.com/Person/Detail/1
how can i extract into a variable:
- Full URL (http://test.mysite.com/Person/Detail/1)
- Root url (开发者_开发百科http://test.mysite.com)
i am sending links inside of emails so i can't just use relative URLs (that why i need something that will get me these URLs
var fullUrl = Request.RawUrl;
.var rootUrl = Request.Url.GetLeftPart(UriPartial.Authority);
Have a look at this answer it may be of use:
How can I return the current action in an ASP.NET MVC view?
The Uri object is useful when working with URLs also
精彩评论