Answered by:
Problem with WebResourc.axd when using Web.Routing

Question
-
User-144286115 posted
Hi All
I am just new on Routing, Trying to use url routing in this way
----------------
Global.asax
-------------------------------------------------------------------
routes.Add(
"View Category",
new Route("{CategoryName}", new CategoryRouteHandler())
{
Constraints = new RouteValueDictionary { { "CategoryName", @"^[a-zA-Z'.]{1,40}$" } }
}
);
Note: there are only one route
void Application_Start(object sender, EventArgs e)
{
RegisterRoutes(RouteTable.Routes);
//RouteDebug.RouteDebugger.RewriteRoutesForTesting(RouteTable.Routes);
}
----------------------------------------------------------------------
--------------------------------
App_Code/CategoryRouteHandler.cs
----------------------------------------------------------------------
public IHttpHandler GetHttpHandler(RequestContext requestContext)
{
string categoryName = requestContext.RouteData.Values["CategoryName"] as string;
if (string.IsNullOrEmpty(categoryName))
return BuildManager.CreateInstanceFromVirtualPath("~/NotFound.aspx", typeof(Page)) as Page;
else
{
// Get information about this category
MydbDataContext DataContext = new MydbDataContext();
UserPersonalInfo userpersonalinfo = DataContext.UserPersonalInfos.Where(c => c.name == categoryName).SingleOrDefault();
if (userpersonalinfo == null)
return Helpers.GetNotFoundHttpHandler();
else
{
// Store the Category object in the Items collection
HttpContext.Current.Items["Category"] = userpersonalinfo;
return BuildManager.CreateInstanceFromVirtualPath("~/CategoryProducts.aspx", typeof(Page)) as Page;
}
}
}
-----------------------------------------------------------------------------------
It works fine when I invoke category stored in our database,
But CategoryRouteHandler.cs caught instanc of Resource.axd!
Other client side content not loded properly Like css and javascript
Firefox shows it syntax error Like:
Error: syntax error
Source File: http://localhost:1098/MyNewWebsite/Login.aspx
Line: 2
Source Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Note: I am using Sqlprovider profile service
I am not understanding what to do with Problem
help please!
Regard
S Samual
Friday, December 25, 2009 1:21 AM
Answers
All replies
-
User-144286115 posted
Any suggestion if you have help me please!
Friday, December 25, 2009 3:29 AM -
User1095964419 posted
This may help you
http://www.priyanonnet.com/Blogs/Posts/3418505412246356805/url-rewriting-with-asp-net-3-5-using-system-web-routing-urlroutingmodule.aspx
Thanks
Deepu
Saturday, December 26, 2009 11:38 AM -
-
User-786643629 posted
check out this link
http://msdn.microsoft.com/en-us/library/system.web.routing.stoproutinghandler.aspx
hopefully you will get the solution here.
Monday, December 28, 2009 8:32 AM