Assign a URL to Url.AbsoluteUri in ASP.NET
Can I assign a URL to Url.AbsoluteUri
in ASP.NE开发者_开发知识库T?
No, it's a read-only property.
You can create a new Uri
though:
var url = new Uri("http://absoluteurl.example.com");
// url.AbsoluteUri is now "http://absoluteurl.example.com"
No, you can't. But you can create a Uri with the desire AbsoluteUri by constructing one:
Uri url = new Uri("http://www.google.com");
No, you cannot, it is derived from the URI. See the MSDN documentation for Uri.AbsoluteUri.
Example from MSDN
Uri baseUri = new Uri("http://www.contoso.com");
Uri myUri = new Uri(baseUri,"catalog/shownew.htm?date=today");
精彩评论