Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8259003
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T02:44:34+00:00 2026-06-08T02:44:34+00:00

What is the best solution to URL Rewriting in .NET 4. I’m looking for

  • 0

What is the best solution to URL Rewriting in .NET 4. I’m looking for an easy solution to rewrite URLs like

“myurl.com/ApplicationName/Kohls” to something like “myurl.com/ApplicationName/index.html?store=Kohls” so I can access the var “Kohls” through the Query String.

I am currently using the Global.asax and it has been working for the above case – but I am running into trouble in the case where the user would enter myurl.com/Application, with no “/” or anything after Application.

I currently have this:

    protected void Application_BeginRequest(object sender, EventArgs e)
    {
        String CurrentURLPath = Request.Path.ToUpper();

        Match nothingAfterRoot = Regex.Match(CurrentURLPath, @"/ApplicationName(/)?$", RegexOptions.IgnoreCase);
        if (nothingAfterRoot.Success)
        {
            HttpContext myContext = HttpContext.Current;
            myContext.RewritePath("/ApplicationName/Default.aspx?store=ABC");
        }
        else
        {
            Match match = Regex.Match(CurrentURLPath, @"/ApplicationName(/)?(\w)*$", RegexOptions.IgnoreCase);
            if (match.Success)
            {
                CurrentURLPath = CurrentURLPath.Trim('/');
                String store= CurrentURLPath.Split("ApplicationName/".ToCharArray())[1];
                HttpContext myContext = HttpContext.Current;
                myContext.RewritePath(String.Format("/ApplicationName/Default.aspx?store={0}", store));
            }
        }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T02:44:37+00:00Added an answer on June 8, 2026 at 2:44 am

    What is the best solution to URL Rewriting in .NET 4

    Use MVC framework if you have the option. The URL rewriting is the default.

    For traditional asp.net sites, I use the UrlRewritingNet.UrlRewriter.dll with the following to my web.config file:

    <configSections>
        <section name="urlrewritingnet" restartOnExternalChanges="true" 
            requirePermission="false" type="UrlRewritingNet.Configuration.UrlRewriteSection, 
            UrlRewritingNet.UrlRewriter" />
    </configSections>
    
    <system.web>
        <urlrewritingnet rewriteOnlyVirtualUrls="true" contextItemsPrefix="QueryString" 
             defaultPage="default.aspx" defaultProvider="RegEx"       
             xmlns="http://www.urlrewriting.net/schemas/config/2006/07">
            <rewrites>
              <add name="ArticleUrlRewrite" virtualUrl="^~/a-(.*)-([\w-]*)\.aspx" 
                   rewriteUrlParameter="ExcludeFromClientQueryString" 
                   destinationUrl="~/article.aspx?id=$1" ignoreCase="true" />
            </rewrites>
        </urlrewritingnet>
    </system.web>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What is the best solution for many-to-many joins in Entity Framework. It looks like
I'm looking for the generally accepted/best solution to this problem. Problem I have a
I'm looking for the best solution for caching thousands of web pages. Right now
I'm currently looking into url-rewriting and how it should be done right and hope
I'm looking for the best solution on how I can ensure I am doing
I am looking for the best solution for my problem. I am currently using
So basically I have a very long url, something like this - http://www.site.com/wp-content/themes/theme/timthumb.php?src=/wp-content/uploads/2012/random-image-name.jpg&w=650&h=0&zc=1&q=100 and
best solution for use access in project for database with security i need to
What is the best solution for inserting boolean values on database if you want
what is the best solution to import large amounts of records into an MySQL

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.