C# - Apply Custom Url Without Using Url-rewriting?
Sep 11, 2010
I am creating a dynamic website in asp.net based on content fetching from MSSQL DB. What I want to do is : everycontent has its own link/url based on contentId-Title. How can I do this?
Example:
Table has :
ID :1
Title : Mytitle
Description :This is description
Extension : .html
Url :
Now, I need to show the all results in a datagrid with title link as:
Title : mytitle => Now whenever anybody clicks on it it will resolve in the form of : "/1-mytitle.html"
In my site, I have used IIS7's URL rewrite module to redirect URLs like http://mysite.com/File.aspx?Name=SomeName into http://mysite.com/SomeName.
It appears that IIS7 has created a corresponding rule check, so that any URL of the sort http://mysite.com/SomeURL is redirected to File.aspx. This is fine in most cases, when the URL is correctly rewritten.
The problem is that in some cases, the file no longer exists - http://mysite.com/SomeName2 will still get redirected to http://mysite.com/File.aspx?Name=SomeName2.
I want to show a custom 404 error page for this URL - how do I trigger the 404 error in global.asax (I have set application error logging and handling in global.asax)? The below code doesn't work.
Response.Status = "404 Not Found" Response.AddHeader("Location", "http://mysite.com/Invalid-File.aspx?" & Request.QueryString.ToString)
i want to apply my custom validator multiple times on a single property. i am using mvc 3 unobtrusive js for validations.i have tried this solution http://www.paraesthesia.com/archive/2010/03/02/the-importance-of-typeid-in-asp.net-mvc-dataannotations-validation-attributes.aspx , but not working for me.I am getting error like this : "Validation type names in unobtrusive client validation rules must be unique."
I am trying to implement URL rewriting technique in my Web application.I have found some articles on net 2 rewrite URL. But i m not able to understand. tell me any API or DLL which will take care of all url rewriting techniques in my Web applications.
I have heard something abt UrlRewriter.ddl . But i have not used it yet. provide me the easiest way to do that. If any sample application is there then it will be better ti understand
I'm currently using URL Rewriting, but I recently stumbled upon this link on Rerouting, and it looks like it's quite simple yet powerful, and easier to implement than URL Rewriting, a "downside" probably is that configurations are not sitting on a web.config file but rather on the code itself, but I was wondering about the differences, and advantages of using one over the other. Having read some resources about routing, I can see the differences, and now I reformulate my question:
Is it worth it to move from URL Rewriting to Routing? Are there any IIS-specific configurations that should be made? Is it recommended to use it on a ASP.NET WebForms Application, or is it oriented to other kind of projects?
I am using the 404 error page and a base class to serve all of my pages.
I have a url /restaurants/?page=2 which displays correctly. The restaurants folder does not physically exists.
I have a paging system, that I want to have the URLs /restaurants/default2.asp as this matches my old asp system.
My Question is can I have a rewrite rule for /restaurants/default2.asp to /restaurants/?page=2 though the restaurants folder does not exist and is served by the 404 error page.
I cant get it to work, and am wondering if the redirect works after the 404 error page is checked
I have developers working on a site for me, they have told me there is no possible way to re-write the URL so there is no second level category e.g. Remove "/category" from this URL http://www.somesite.com/category/page.aspx I understand that page.aspx can simply go in the root folder on the server however I don't want to do this as adding heaps of pages will slow down server load time
I am using urlrewriter.net and I am trying to make a redirection. So here is the condition,If the requested url doesn't end with a / (slash) and then add / at the end of the url an redirect to added urlSo if the url is "http://www.something.com/cases" then add / and redirect it to "http://www.something.com/cases/"
how do i create a number of pages lat's say pages "1-2-3-4-5" how do i make the name look different for all the users like page "1.aspx" when opend by users it will be "bladde.aspx" .
secondly how do i only assign one of the five pages to one user only and then the second page to a second user withour assigning the same page to multiple users
I am running into an issue where I am trying to implement SEO friendly links in an ASP.Net 3.5 application with IIS6. The issue is that when I try to use a url like [URL] it isn't directed to the ASP.Net pipeline, so I am unable to route the request to the correct physical aspx file. With ISAPI_Rewrite I know I can redirect a request to the specific page, but is there a way to have a request sent to the ASP.Net pipeline, so I can manipulate the request using the built-in routing engine.
I have used FCKeditor in my project. It worked fine before i add url rewriting in my project.Now i can not upload images from my fckeditor properly.I am using Intelligencia.UrlRewriter for url rewriting in asp.net
I am using the UrlRewriter.NET library to perform URL rewriting. I noticed that themes do not work properly as the browser tries to retrieve the CSS file incorrectly.
The link tag generated by ASP.NET automatically is as follows:
URL typed into browser: localhost:1708/BloggingEngine/aa Displays fine
URL typed into browser: localhost:1708/BloggingEngine/aa/ Browser does not load the CSS file
I can probably fix the problem by prefixing a "/" before the URL in the href attribute, but this is dynamically generated by ASP.net depending on selected theme and I have no control over it.
I am implementing URL rewriting and this is not a MVC app, I am using .Net 3.5 Framework here is my simple setup: 1. My Link Page I have a link on my index.aspx page
(notice SEO friendly URL, purpose of Routing) --> <asp:HyperLink ID="HyperLink1" NavigateUrl="~/Category/Engine" runat="server">Engine</asp:HyperLink>
2. Global.asax:
protected void Application_Start(object sender, EventArgs e) { RegisterRoutes(); } private static void RegisterRoutes() { System.Web.Routing.RouteTable.Routes.Add("category", new System.Web.Routing.Route("Category/{name}", new CategoryRouteHandler("~/catalog.aspx")));.........
how could i do advance url re-write in asp.net3.5. when we post question in stackoverflow then our question is listed as hyperlink like below one. What is dependency injection? when we click on link then a dynamic page is show. so i want know if there is a hyperlink which have href like [URL] actualy i want that when user click on above link then user will be redirect to page where url will be shown in address toolbar like [URL]. how could i achieve it without touching IIS. how to write the code.
This is a general question about dealing with URL Rewriting in a development environment. I'm developing a CMS to learn ASP.NET/C#, and I will of course need to implement URL Rewriting. This technique is known to me since I've been using with PHP for several years. However in PHP, you can have a local HTTP server, modify the PHP content directly, refresh the page and see the results. Of course in ASP.NET it's not exactly the same, since you need to compile and then publish the code. The problem I have is that I need to check the URL Rewriting-friendly links my code will generate in my development environment - basically, make the ASP.NET Development Server compatible with URL Rewrite. Or maybe not. My question really is: what is the best solution to do that? Use IIS/Apache2 (w/ Mono) for the development server?
I want to create an asp.net white-label site [URL], that could be styled for each of our clients according to their specific needs. So for example, client abc would see the site in their corporate colours and be accessed through their specific url http://abc.com. Likewise client xyz would see the site in their own styling and url http://xyz.com.
Typing either url, in effect, takes the user to http://whitelabel.com where the styling is applied, and the client's url structure is retained.
I was thinking of URL rewriting using URLRewriter.Net [URL], or similar, mapping the incoming address to a client id and applying the theme accordingly. So, a url rewrite rule may be something like
eg: Folder/StaticPage.aspx?PageName=TestPage is re-written as
Folder/TestPage
This works fine on my local dev. machine on the Cassini server. But when its hosted in IIS (5.1 & 7.0) it fails to work, with the error as 404 Page Not Found.
I've inherited a website which has been developed for IIS server. The hyperlinks in this website have a href attribute with the human readable form that appears in the url in the browser's searchbar.InApplication BeginRequest(), there is a method which will convert this into the acutal location of the page within the website's file structure.This works fine when running the website on IIS. However, when I am using the ASP.NET development server,the links do not work and I get a page not found error.I have noticed that Application_BeginRequest() is never called for the links when run using the ASP.NET development server. I have read that the ASP.NET development server will not serve pages that are outside of the application scope (http://msdn.microsoft.com/en-us/library/58wxa9w5%28VS.80%29.aspx),as the human-readable urls would appear to be when first processed by the server.Bear in mind that the urls in the aspx files are in human readable form, so I can't just use ResolveUrl(), because they don't correspond to files in the internal file structure until they have been re-written.I want to get the website running on the ASP.NET development server so that I can test it locally on my machine, which I can't really do if I can't get the url re-writing to work.
I'm trying to enable rewrited urls in my project.it's very good described in this post: urlrewriting by scottgu It works very well when im running it on localhost, but as soon as i upload it to my host (.net 3.5), it doesn't work! i always get redirected to a 404 page!Is there a configuration needed to enable this? as scottgu says no, but i don't find out why it's not working.