I am trying the new feature of .NET 4.0 - url routing but not able to fetch information passed in the url. Following is the code :
GLOBAL.ASPX.CS
protected void Application_Start(object sender, EventArgs e)
{
SetRouting(RouteTable.Routes);
}
private void SetRouting(RouteCollection routeCollection)
{
routeCollection.MapPageRoute("Company",
"Company/{CompanyName}",
"~/Asset/RequestForm.aspx", true, new RouteValueDictionary { { "CompanyName", "?CompanyName" } });
routeCollection.MapPageRoute("Deal",
"Company/{CompanyName}/{DealName}",
"~/Asset/RequestForm.aspx", true, new RouteValueDictionary { { "DealName", "?DealName" } });
routeCollection.MapPageRoute("ClientRoute",
"Client/{ClientCompanyName}",
"~/User/Login.aspx", true, new RouteValueDictionary { { "ClientCompanyName", "?ClientCompanyName" } });
}
Login.aspx:
private string CompanyName {
get
{
if (Page.RouteData.Values["ClientCompanyName"] == null)
{
return null;
}
return Page.RouteData.Values["ClientCompanyName"].ToString();
}
}
Now the property mentioned above returns null even when i use Client/Google in the url. When i reset IIS (IIS 6) and do it for first time, it returns value. Otherwise it gives null.
ANY CLUE ??