LT1415
asked on
BC30109: 'String' is a class type, and so is not a valid expression.
I have a small snippet of c# coding in my aspx page which is supposed to check for
a user name. There is no coding in the back end.
I am getting an error message:
on this line
string userName = Request.QueryString["UserN ame"];
BC30109: 'String' is a class type, and so is not a valid expression error.
<%@ Page Language="c#" Inherits="peepapers" CodeFile="peepapers.aspx.c s" %>
<%@ Register TagPrefix="pu" TagName="footer" Src="footer.ascx" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<%
string userName = Request.QueryString["UserN ame"];
if(userName != "")
{
Session["UserName"] = userName;
}
{
Session["UserName"] = userName;
if (String.IsNullOrEmpty(user Name) == true)
Response.Redirect("http://www.blah.com", false);
}
%>
I don't know if this makes a difference or not but,
The page is supposed to be asp.net 2.0.It is is just a simple page and not an application.
The parent directory is also asp.net 2.0
However the error from the Web page
States that the version information is 1.1.4
Thanks
a user name. There is no coding in the back end.
I am getting an error message:
on this line
string userName = Request.QueryString["UserN
BC30109: 'String' is a class type, and so is not a valid expression error.
<%@ Page Language="c#" Inherits="peepapers" CodeFile="peepapers.aspx.c
<%@ Register TagPrefix="pu" TagName="footer" Src="footer.ascx" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<%
string userName = Request.QueryString["UserN
if(userName != "")
{
Session["UserName"] = userName;
}
{
Session["UserName"] = userName;
if (String.IsNullOrEmpty(user
Response.Redirect("http://www.blah.com", false);
}
%>
I don't know if this makes a difference or not but,
The page is supposed to be asp.net 2.0.It is is just a simple page and not an application.
The parent directory is also asp.net 2.0
However the error from the Web page
States that the version information is 1.1.4
Thanks
ASKER
Thanks for you response. I received this error using the snippet
Compiler Error Message: BC30451: Name 'var' is not declared
var keyword does not work with asp.net 2.0. var is .net 3.0 feature.
Request.QueryString.GetVal ues("UserN ame")[0] instead of Request.QueryString["UserN ame"]
Request.QueryString.GetVal
ASKER
Thank you SriVaddadi:
I tried using the snippet below.
I sure that the server is running aspnet 2.0 framework.
CS0246: The type or namespace name 'var' could not be found (are you
missing a using directive or an assembly reference?)
<%
var UserName = Request.QueryString.GetVal ues("UserN ame")[0];
if(!string.IsNullOrEmpty(u serName))
{
Session["UserName"] = userName;
}
if (!string.IsNullOrEmpty(Ses sion["User Name"] as string))
{
Response.Redirect("http://www.blah.com", false);
}
%>
I tried using the snippet below.
I sure that the server is running aspnet 2.0 framework.
CS0246: The type or namespace name 'var' could not be found (are you
missing a using directive or an assembly reference?)
<%
var UserName = Request.QueryString.GetVal
if(!string.IsNullOrEmpty(u
{
Session["UserName"] = userName;
}
if (!string.IsNullOrEmpty(Ses
{
Response.Redirect("http://www.blah.com", false);
}
%>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
i did not mean
var UserName = Request.QueryString.GetVal ues("UserN ame")[0];
Sorry for the confusion. This is what I wanted you to try.
string userName = Request.QueryString.GetVal ues("UserN ame")[0];
var UserName = Request.QueryString.GetVal
Sorry for the confusion. This is what I wanted you to try.
string userName = Request.QueryString.GetVal
Open in new window