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 200303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T17:06:00+00:00 2026-05-11T17:06:00+00:00

When I try to rewrite a URL in ASP.NET I’m finding that the URL

  • 0

When I try to rewrite a URL in ASP.NET I’m finding that the URL changes on the user’s browser. I’m using WCF REST services and I want to change the way that you access URLs. See the code example below.

I have an HttpModule that is intercepting requests.

public class FormatModule : IHttpModule
{
    #region IHttpModule Members

    public void Dispose()
    {
        throw new NotImplementedException();
    }

    public void Init(HttpApplication application)
    {
        application.BeginRequest += new EventHandler(application_BeginRequest);
    }

    void application_BeginRequest(object sender, EventArgs e)
    {
        HttpContext context = HttpContext.Current;
        if (context.Request.RawUrl.Contains(".pox")) 
            context.RewritePath("~/Lab1Service.svc?format=pox", false);
        else if (context.Request.RawUrl.Contains(".json")) 
            context.RewritePath("~/Lab1Service.svc?format=json", false);
    }

    #endregion
}

The problem occurs when the users visits the URL in their browser.

http://localhost/Lab1Service.svc.pox, instead the URL changes in the browser to http://localhost/Lab1Service.svc?format=pox.

  • 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-05-11T17:06:00+00:00Added an answer on May 11, 2026 at 5:06 pm

    I resolved this. It appears that if you don’t include the trailing backslash after the .svc extension the URL REDIRECTS instead of REWRITING.

    This was my original

    context.RewritePath("~/Lab1Service.svc?format=pox", false);

    This is the corrected version (notice the forward slash after the .svc)

    context.RewritePath("~/Lab1Service.svc/?format=pox", false);
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have set up some User Friendly URL rules in IIS7 using the URL
The Problem When I try to get to my ASP.NET Web Page Razor pages
I'm try to rewrite my url http://www.domain.com/live/randomword it should go rewrite to http://www.domain.com/live/?cat=randomword here
I am trying to do a URL Rewrite, but no matter how I try,
Today I try to rewrite some ugly url in order to be cache by
I try to rewrite this method using short-hand if: public string checkInputParamters(string baseUrl, string
I'm trying to implement a REST-style URL with a mod-rewrite turned on in .htaccess.
I'm using the Application Request Routing and URL Rewrite modules in IIS7.5 to host
Should I try to actually upgrade my existing app, or just rewrite it mostly
try: spam.foo except AttributeError: do_somthing() (Is it wise to check an attribute like that

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.