This will probably be a simple question for some. I am just delving into the asp.net world. I have inherited a php script that I need to convert to asp.net. I know that there are converters out there but I can't use them. The gist of my issue is that I have numerous "if" statement that follow the same PHP format.
PHP format is:
if ($_GET['id'] == "Word") {
$location = "http://www.word.com" ;
}
How should this look in asp.net?
If statement is comparing querystring - id with "word". $_GET
stands for get request, that is Request.QueryString
in asp.net ( i mean C# or vb.net). So asp.net translation will be like following.
C#.net version
if(Request.QueryString["id"]!= null && Request.QueryString["id"].ToString() == "Word")
{
// write code for assigning location variable
}
VB.net version
If Request.QueryString("id") IsNot Nothing AndAlso Request.QueryString("id") = "Word" Then
' write code for assigning location variable
End If
I would suggest do a null check of Request.Querystring
before comparison.