Web Forms :: Implement URL Routing
Apr 20, 2013i want to avoid displaying page as [URL] It should show as [URL]....
View 1 Repliesi want to avoid displaying page as [URL] It should show as [URL]....
View 1 RepliesWe have a shopping cart product. I am trying to implement ASP.Net 4 URL Routing. The problem I have is with image and other resource folders. I can resolve all the links that are defined within the pages and in the code behind. But, some of the links come from html text entered by users.
Using absolute path is not an option. There are some work arounds. But, I want to avoid those work-arounds, because we don't want to burden the users. Is there a way to achieve this through URL Routing?
E.g. The image path derived from the rewritten page: [URL]
Is there a way to achieve this without any patch work?
I'm trying to wrap my mind around the way ASP.NET MVC implements routing.
From what is my current understanding, it seems my route string much have a "{controller}" and "{action}", otherwise it doesn't work?
How would I define the route that using a SearchController and Search action taking both SearchKeywords and SearchCaseSensitive arguments had the following URL?
domain/SearchKeywords/CaseSensitive
Even simpler, how do I map domain to controller SearchController and to Search?
Is it advisable to implement url routing for an asp.net(webforms) website which is one year old... What are the factors to be considered before implementing....
Edit: It is a web based product website developed my company and users should pay for using it...
I need to implement Routing or Url-Rewriting in my application. So, is there any utility like logging utility Elmah. I dont want to write much code, I need to configure and start playing.
View 2 RepliesI am using ASP.NET 4.0 Web Forms. I learned that, in order to optimize my Web Application for Search Engine, I must implement custom 404 page. But the way Microsoft tell us to implement custom 404 (within Web.Config file), that is not good for SEO. Microsoft says,
<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
<error statusCode="404" redirect="Page-Not-Found.aspx" />
</customErrors>
But when the page is not found, IIS issue 302 redirect to Page-Not-Found.aspx page which is not good. So, I implemented custom 404 page using Routing technique that is available in ASP.NET 3.5 SP1 and 4.0. I used the following router in Global.asax page
Many hosting companies let you define which page will be shown to the user if the user goes to a page that does not exist. If you define some .aspx page then it will execute and be shown.
My question is, why not use this for routing. since I can parse the users URL and then do a server.transfer to the page I want. I checked and there is no redirect sent to the client and the http headers are HTTP/1.1 200 OK.
So, is this a good idea for servers that don't have ASP.NET 3.5 SP1 or if you are not using MVC?
I tried everything I could find, but still does not work on IIS routing.
View 2 RepliesI am using:
ASP.NET 3.5 SP1 with Web Forms Routing thru Global.asax (System.Web.Routing and RegisterRoutes)IIS 7
Everything is working fine in my local machine, but it gives the following error in my hosting environment:
Could not load file or assembly 'System.Web.Routing, Version=3.5.0.0, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
I did everything inside my web.config file mentioned in the following link:
[URL]
But I am still getting the above error.
What else am I supposed to do fix the error?
I have a Web application where i have added a reference to a RESTful WCF. I got the WCF url Routing to work in my webapplication by adding Inherits="RestService.Global" to the Web applications Global.asax.
<%@ Application Codebehind="Global.asax.cs" Inherits="RestService.Global" Language="C#" %>
But then i tried to create url Routing for the Web application and it does not work with the Inherits="RestService.Global" in the Global.asax. If i take it away it works fine. Is there a correct way to do this.
I'm trying to create my own CMS and I've gotten a little bit stuck at the stage of URL routing.
I want clean URLs without extensions and I'd like to be able to create and modify them in a web based interface without any messing around with IIS or actual files.
I've seen how to create a static route, but for that I need to go into my Global.asax file and manually add it.I would like to have all of these routes stored in a database so that I can easily modify them later.
Does anyone know how this can be achieved?
Just for extra information, I will be attempting to create a feature so that if a path exists, but is later changed, a 301 redirect is created to the new URL, is this also possible? (My first problem is the main issue, but thought I might ask this as well just in case it makes a difference)
How to handle asp.net mvc routing along with asp.net webform routing. I have merged my mvc app into my existing web application. In my web application i have implement routing as below:
routes.Add("View Product Details", new Route("Product/{City}/{Manufacturer}/{Name}/{ProductID}/{*ProductType}"));
Similarly i have implemented routing in mvc as below
routes.MapRoute("Product Details",
"Product/{City}/{Manufacturer}/{Name}/{ProductID}/{ProductType}",
new
{
controller = "Home",
action = "ProductDetails",
City= UrlParameter.Optional,
Manufacturer= UrlParameter.Optional,
Name= UrlParameter.Optional,
ProductID= UrlParameter.Optional,
ProductType= UrlParameter.Optional
});
How to handle both pages, as one is custom web form while other is asp.net mvc view?
Response.RedirectPermanent(Url); can redirect permanently to a url.
However, during my SEO process, I decided to change my routhing rule.
For example,
I change "/tag/{tag}-quotes" routing rule to "quoes-about/{tag}", but I don't want to lose all the traffic to old routing url.
What is the best way to handle this permanent redirection?
This is more of an ASP.NET Routing question than MVC, so I will gladly move this post to another forum if prompted!
I am using ASP.NET Routing without using MVC.
I am trying to implement the following URLs:
[URL]
[URL]
[URL]
Each page can have sub-pages:
[URL]
or even sub-sub-pages:
[URL]
I am currently implementing this as follows:
1) GLOBAL.ASAX
[Code]....
2) ROUTE HANDLER CLASSES
[Code]....
I am trying to implement Url routing in 4.0 by following example [URL]
Works fine..
Now the scenario is that i have gridview with object datasource which accepts "Name" as query string.
[Code]....
i tried this code. But i couldn't get the value in QueryString Field?? How to handle in this situation?? + How to implement (the link example in net 3.5)? because i don't "
[Code]....
" attribute in 3.5. i have few existing application in 3.5 so thought of implementing there too.
I have web app written in .net 4.0 using url routing. It works fine in the development environment in VS 2010.But It's not working after publishing to iis6. I keep having HTTP error 404. I tried Wildcard mapping with v4.0.0319aspnet_isapi.dll and it's not working.
View 1 RepliesIt is possible to use Asp.net Menu with Asp.net Route, the NavigatorUrl handle all the website address.
View 1 Replieshow i would set up the routes table from a databse i.e can you do something like this i no i should load from a text file created from the save button of my cms page section but dont no how to do that.
rc.MapPageRoute (
"page",
"page/{Type}",
"~/cms.aspx");
// is their some way to load this into the global asx from a text file if so how?
"page/{Type}",
//URL with parameter
"~/cms.aspx");
//Web Form to handle
I try to use routing feature on vs 2010 but it isn't running? May I have some wrong . Here is my code:
[code]....
I am trying to implement URL Routing for a non MVC application. Here's my original [URL] to [URL] I have difficulty when the page has query strings in the URL. This is the route handler I have so far:
public class CustomRouteHandler : IRouteHandler
{
public IHttpHandler GetHttpHandler(RequestContext requestContext)
{
return BuildManager.CreateInstanceFromVirtualPath("ProcessStuff.aspx", typeof(Page)) as Page;
}
}
I started using url routing for my web application. It's a dynamic website and it has more than 50k pages. It looks like now it works slower. how to optimize it, to improve it and make it more efficient?
View 1 RepliesI am setting up URL Routing on my existing project. I am not using mvc. The routing only working like this: [url] not working with single word like this: [url] I am getting error message: The resource cannot be found. Looks like when I using single word, application think that is folder?
View 5 RepliesThe image is not getting displayed on the page if it is called through the routing engine, and the image is displayed on the same page if the page is directly called (explicitly appending .aspx).
Only those image which are set using <img> tag are not displayed whereas the ones whose value is grabbed using the routed url and into the <asp:Image> tag are dislplayed properly.
I tried adding the following to global.asax file, but it did not.
When I check the image source using the firebug in html source code the path is available with all the attributes (src, height, width, alt) but the image is not displayed on the screen.
I'm using ASP.NET 4 WebForms, and can't find information about creating wildcard subdomains.
For example, url user22.example.com must point to example.com/users/user22.
May i implement this feature only with Routing (without IIS url-rewrite, or another external tools)?
I am using System.Web.Routing with ASP.NET (3.5) Web Forms that will URL rewrite the following URL from
http://www.myurl.com/campaign/abc
http://www.myurl.com/default.aspx?campaign=abc
The code is as below:
public static void RegisterRoutes(RouteCollection routes)
{
routes.Add("CampaignRoute", new Route
(
"{campaign_code}",
new CustomRouteHandler("~/default.aspx")
));
}
IRouteHandler implementation:
public class CustomRouteHandler : IRouteHandler
{
public CustomRouteHandler(string virtualPath)
{
VirtualPath = virtualPath;
}
public string VirtualPath { get; private set; }
public IHttpHandler GetHttpHandler(RequestContext
requestContext)
{
if (requestContext.RouteData.Values.ContainsKey("campaign_code"))
{
var code = requestContext.RouteData.Values["campaign_code"].ToString();
HttpContext.Current.RewritePath(
string.Concat(
VirtualPath,
"?campaign=" + code));
}
var page = BuildManager.CreateInstanceFromVirtualPath
(VirtualPath, typeof(Page)) as IHttpHandler;
return page;
}
However I noticed there are too many things to change on my existing aspx pages (i.e. links to javascript, links to css files).
So I am thinking if there's a way to keep above code but in the end rather than a rewrite just do a Request.Redirect or Server.Transfer to minimize the changes needed. So the purpose of using System.Web.Routing becomes solely for URL friendly on the first entry.How to ignore the rest of the patterns other than specificed in the code?