1

Can someone explain why people use the @ sign in things like page redirections?

For example;

response.redirect(@"mypage.aspx");

Seems to work exactly the same as;

response.redirect("mypage.aspx");

I would like to know the purpose of the @ sign.

Stephen85
  • 250
  • 1
  • 15

1 Answers1

2

The @ before the string indicates the string is a verbatim string: So if you are redirecting to a page that is not on the current location as the view, you could say response.redirect(@"path\mypage.aspx"). Without the @, you have to say response.redirect("path\\mypage.aspx")

For your code, you do not need it since the page you are redirecting to is on the same location.

Reference: https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/tokens/verbatim

Frank Fajardo
  • 7,034
  • 1
  • 29
  • 47
  • 1
    Perfect explanation and that explains it clearly. +1 for providing the link to the reference material. I shall read more into this to fully understand it. Thanks, Frank! – Stephen85 Feb 04 '21 at 05:37