.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

URL ReWrite with UrlRewrite.net

Posted By:      Posted Date: September 07, 2010    Points: 0   Category :ASP.Net
I'm trying to set up Url-rewrite-function on our site. For this I will use the Approach 2 on http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx    In that exampel they are using this <rewriter>    <rewrite url="~/products/books.aspx" to="~/products.aspx?category=books" />    <rewrite url="~/products/CDs.aspx" to="~/products.aspx?category=CDs" />    <rewrite url="~/products/DVDs.aspx" to="~/products.aspx?category=DVDs" />  </rewriter>   But I want just a keyword direct aftrer the site name like this www.site.com/books  

View Complete Post

More Related Resource Links

Url rewrite with timer



I'm trying to rewrite my urls, which kinda work now.

The problem is that in my page i'm using a timer to refresh the data every couple of seconds.
But in Mozilla firebug I can see that the url keeps changing: it's getting bigger after each timer update, like this:


etc etc, until it returns a 404 not found.

What can I do to prevent this?


URL Rewrite causes AppSettings to Fail?


Hi there,

I just implemented basic URL rewriting to change a page from, for example, /member.aspx?id=123 to /member.aspx/erik.  That works and I'm happy with it.  However, I am now getting an error message that states "the connectionstring property has not been initialized".  Normally, I've been storing the connectionstring in web.config, and I access it with:

Dim Connect As SqlConnection = New SqlConnection
Dim ConnectString As String
ConnectString = ConfigurationManager.AppSettings("linktomysite")
Connect.ConnectionString = ConnectString

This is what I do on every other page of the site and it works fine.  The only way it will work on the page where I'm URL re-writing, however, is if I replace "ConfigurationManager.AppSettings("linktomysite")" with the actual connection string itself.  For security reasons, obviously I would prefer to keep that info out of the page.  What can I do?



Arabic QueryString with Url Rewrite Solution


Alsalamo 3alaykom ,

as we know that if you use Intelligencia.UrlRewriter.RewriterHttpModule or IIS URL Rewriting , we will face problems with arabic urls

as this

http://localhost:1234/Pages/???? ?????? ?????? ??????????

and the Rule is :

<rewrite url="~/Pages/(.+)" to="~/ShowPages.aspx?Page=$1" />

you will recive the QueryString["Page"] Like this

نائب العميد للشؤون الأكاديمية

so it's a big problem , and there is a solution that is :

remove the Rule of that rewriting ,,

<rewrite url="~/Pages/(.+)" to="~/ShowPages.aspx?Page=$1" />

then open your Global.asax file and Application_BeginRequest method exactly

use the following code to handle you request

void Application_BeginRequest(object sender, EventArgs e)
if (HttpContext.Current.Request.Url.ToString().Contains("/Pages/"))
	String[] txt= Regex.Split(HttpContext.Current.Request.Url.ToString(), @"/");
	String page = txt[txt.Length-1];

.NET Internals: Rewrite MSIL Code on the Fly with the .NET Framework Profiling API


In this article, the author shows how to dynamically rewrite Microsoft Intermediate Language code on the fly using the Profiling API of the CLR. Unlike approaches based on Reflection.Emit, this scheme works with the existing assemblies and doesn't require the creation of proxy or dynamic assemblies. The need for IL code rewriting emerges when you want to make your changes transparent to the client and preserve the identity of classes. This technique can be used for creation of interceptors, pre- and post-processing method calls, and code instrumentation and verification.

Aleksandr Mikunov

MSDN Magazine September 2003

Want to create Page URL rewrite based on Users GUID and Display name?



I am using the asp.net membership. 

On my site I have a Profile.aspx page.

In the code behind of this page,  i get the logged in UserId (Guid) and pass

this to a method in my DAL. GetUserByUserId()


In my database I have a Table called Member which the method gets the data from

and displays details on the page about  the user.


What I want to happen is when they have logged in and are diverted to Profile.aspx,

the page URL shows www.MyWebSite/Profile/UsersName 

for example



is this possible. In my Member table I have FirstName and LastName columns or do I get the

name from the membership table.


even better would be they go straight to www.MyWebsite/JohnSmith.aspx


thank you for any help






Url Rewrite for web service ...


Hello ,

how i can rewrite url for an web service ?!

i use it :

<add name="WebService" virtualUrl="^~/include/(.*).do" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="~/Def/WebService/$1.asmx" ignoreCase="true"/>

but when run sie , get some error(405 (Method Not Allowed) OR 500 ..) ...

Now I need to how to rewrite the web service address.

please help me ...

thanks .

Url Rewrite


Hi Everyone,

I have used url rewrite before, but have not yet attempted to do the following.
I have one site (www.somesite.co.za) which is being 301'ed to (www.sub.someothersite.co.za).
This work fine of course.

Is it possible to actually change the domain name in the url re-write? I would like to
hide the fact that the user is actually on a sub site on another domain. For example
if you browse to www.somesite.co.za, the url now reads www.subsite.someothersite.co.za.
I would like to re-write it to still be www.somesite.co.za

Any help will be greatly appreciated.

Thank you


Louis Lewis 

Urlrewrite, big problem

I'm trying to get urlrewrite to work on my site. Everything works fine except when I browse into categories, then I get all text and pics but the page will not load css. I can't figure out what to do. Here is my code. When I go into department and product everything works fine, it's only categories that not will work.<configSections> <section name="rewriter" requirePermission="false" type="Intelligencia.UrlRewriter.Configuration.RewriterConfigurationSectionHandler,Intelligencia.UrlRewriter"/> </configSections> <rewriter> <!-- Rewrite department pages --> <rewrite url="^.*-d([0-9]+)/?$" to="~/Catalog.aspx?DepartmentID=$1" processing="stop" /> <rewrite url="^.*-d([0-9]+)/page-([0-9]+)/?$" to="~/Catalog.aspx?DepartmentID=$1&Page=$2" processing="stop" /> <!-- Rewrite category pages --> <rewrite url="^.*-d([0-9]+)/.*-c([0-9]+)/?$" to="~/Catalog.aspx?DepartmentId=$1&CategoryId=$2" processing="stop" /> <rewrite url="^.*-d([0-9]+)/.*-c([0-9]+)/page-([0-9]+)/?$" to="~/Catalog.aspx?DepartmentId=$1&CategoryId=$2&Page=$3" processing="stop" /> <!-- Rewrite product details pages --> <rewrite url=&quo

Url Rewrite for web service ...

Hello , how i can rewrite url for an web service ?! i use it :   <add name="WebService" virtualUrl="^~/include/(.*).do" rewriteUrlParameter="ExcludeFromClientQueryString" destinationUrl="~/Def/WebService/$1.asmx" ignoreCase="true"/>  but when run site and call a method(webservice.asmx/ChangeImage) , get error :The resource cannot be found. and if call web service mathod with jquery get error(405:Method Not Allowed). this is replay : <html> <head> <title>The HTTP verb POST used to access path '/Game-Root/Def/WebService/webservice.asmx/ChangeImage' is not allowed.</title> <style> body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;} p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px} b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px} H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red } H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon } pre {font-family:"Lucida Console";font-size: .9em} .marker {font-weight: bold; color: black;text-decoration: none;} .version {color: gray;} .error {margin-bottom: 10px;} .expandable { text-decoration:

URL-rewrite problem or sth else?

WelcomeI have a little problem with the *. js and *. css (probably also with others). When they move up to the header (or anywhere) I get something like that. Any ideas?Tuinel

asp:LoginStatus with url rewrite - postback url

hi ! I have done a url rewrite in my website and I did the following for handling the postbacks;    protected void Page_Load(object sender, EventArgs e)     {         this.form1.Action = Request.RawUrl;    protected void Page_Load(object sender, EventArgs e)    {        this.form1.Action = Request.RawUrl;it worked. but no with loginstatus button?? anyone knows why??

Url rewrite + ScriptManager = Client side error...

Hi All,   I am trying to build a asp.net website with url rewriting. I have retrieved a rewrite rule from my web host (see below) that I have added to my web.config file. The rule redirects all urls to my default.aspx as intended and every thing seems to work as it should.<rewrite> <rules> <rule name="Rewrite All" stopProcessing="true"> <match url="^(.*)$" /> <conditions logicalGrouping="MatchAll"> <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> </conditions> <action type="Rewrite" url="Default.aspx" /> </rule> </rules> </rewrite>.until I add a ScriptManager to my page for partial updating of UpdatePanels. When I do this i get a client side (javascript) error as follows (see below). The error occures both on the initial page load and on postbacks. Viewstate is still working, but partial updates and ajax or any other javascript is not working because of the error below.Chrome javascript console: WebResource.axd:3Uncaught SyntaxError: Unexpected token <WebResource.axdResource interpreted as script but

URLRewrite (without any modules installed)

URLRewrite (without any modules installed) Hello All; My hosting provided has IIS6, and will not install any modules for the URLRewrite. So, I am stuck to improvisions of trying to get something to work. OK. I have tested the below code on: IIS5.1 (XP) and IIS7.5 (Win7) Debugging through VS2008 Pro, and in IIS5.1 it stops at the break that I set In IIS7.5, it does not stop at the break, and they both give me a 404 not found error (IIS5, when I F5 to compile through) The code that I was given is: Within the Global.asax file, this Suppse to run /User/yourname And work, but this is not the case with me here on either of the 2 systems.    void Application_BeginRequest(object sender, EventArgs e)     {         //URL example: www.site.com/User/UserName         string url = Request.Url.ToString();         if (url.Contains("/User/"))         {             //Get the username             string[] temp = url.Split('/');             string userName = temp[temp.Length - 1];             //Redirect             Context.RewritePath("~/Test.aspx?username=" + userNam

Can URL Rewrite work for Web Services?

I have a WebService and the URL that we use to access it is as follows: https://our.domain.name/ForCertain/myservice.svc/Method1 https://our.domain.name/ForCertain/myservice.svc/Method2 etc. I have tried in vain to remove the myservice.svc node from the url using the URL Rewrite module that I installed in IIS 7, but I can not seem toget it to work.  So my questions are: 1) Does this work for web services at all? 2) If so, where can I find an example? I want to end up with: https://our.domain.name/ForCertain/Method1 https://our.domain.name/ForCertain/Method2 etc. The site name is https://our.domain.name/ForCertain and the individual methods are WebMethods exposed in the service.  myservice.svc is obviously the svc file name in the web site. Any help is appreciated.  Thanks.

url rewrite for images(.jpg file extension not .aspx)



I have stored DB images. and I try to access images using url rewrite. But it is not happaning.

I tried this scott methord. http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx. i tried with Application_BeginRequest, but no use

Basically Client don't want to use .aspx extension for images

Is it possible acess db images with out using .aspx file name extension?  then can anybody tell me how to achieve this!!!!!!!!!!!!

My sample url is "www.sample.com/images/folder/imagefilename.jpg" I want to rewrite to "www.sample.com/images/pimges/default.aspx?file=imagefilename.jpg&cat=folder"



Url Rewrite Simple using C#


suppose i have a page default.aspx

and i two links on that

 <form id="form1" runat="server">
    <a href="Default.aspx?id=1" target="_blank">Daily</a><br /> 
    <a href="Default.aspx?id=2" target=_blank>Accounts</a><br />
    <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>

and on page Load

if (!IsPostBack)
            if (Request.QueryString["id"] != null)

                Label1.Text = Request.QueryString["id"];

this i can do it by query string but what i want exactly

it should display in Internet Eplorer Status Bar when


instead of Default.aspx?id=1

i want currently to do this with implementing IHttpModule

i have already went through a video in asp.net Road and Mountain Bike it's a little bit confusing

can some one explain me how this can be done

and later on with IIS 7


url rewrite problem



i have the followig code in my app_code and config

<httpModules>add name="UrlRewrite"

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend