0

Can I assign a URL to Url.AbsoluteUri in ASP.NET?

Michael Petrotta
  • 59,888
  • 27
  • 145
  • 179
Navin Leon
  • 1,136
  • 3
  • 22
  • 44

3 Answers3

1

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"
Cameron
  • 96,106
  • 25
  • 196
  • 225
  • @Navin: the way to thank someone for their response is to click the "^" button to upvote their answer. Saying so in a comment just adds noise, and will likely be removed. – John Saunders Mar 22 '11 at 05:30
0

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");
Fun Mun Pieng
  • 6,751
  • 3
  • 28
  • 30
0

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");
Quintin Robinson
  • 81,193
  • 14
  • 123
  • 132