Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. url rewriting

url rewriting

Scheduled Pinned Locked Moved C#
sysadminhelpquestion
9 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    icanmakeiteasy
    wrote on last edited by
    #1

    Hi,

    protected void Application_BeginRequest(object sender, EventArgs e)
    {
    HttpContext context = HttpContext.Current;

            if (context.Request.FilePath.ToString().StartsWith("/hotels-in-"))
            {
                context.RewritePath("country.aspx");
            }
            
        }
    

    this is my code in global.asax.cs file this code is working in local system but when i uploaded the project to server its not working what to do??........ please help me...thx

    icanmakeiteasy

    G 1 Reply Last reply
    0
    • I icanmakeiteasy

      Hi,

      protected void Application_BeginRequest(object sender, EventArgs e)
      {
      HttpContext context = HttpContext.Current;

              if (context.Request.FilePath.ToString().StartsWith("/hotels-in-"))
              {
                  context.RewritePath("country.aspx");
              }
              
          }
      

      this is my code in global.asax.cs file this code is working in local system but when i uploaded the project to server its not working what to do??........ please help me...thx

      icanmakeiteasy

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      When you say that it's "not working", what do you mean? What happens, and how does that differ from what you expect? Do you get any error message?

      Despite everything, the person most likely to be fooling you next is yourself.

      I J 2 Replies Last reply
      0
      • G Guffa

        When you say that it's "not working", what do you mean? What happens, and how does that differ from what you expect? Do you get any error message?

        Despite everything, the person most likely to be fooling you next is yourself.

        I Offline
        I Offline
        icanmakeiteasy
        wrote on last edited by
        #3

        http://........../hotels-in-India //url is like this Not Found The requested document was not found on this server. just its showing like this

        icanmakeiteasy

        G 1 Reply Last reply
        0
        • I icanmakeiteasy

          http://........../hotels-in-India //url is like this Not Found The requested document was not found on this server. just its showing like this

          icanmakeiteasy

          G Offline
          G Offline
          Guffa
          wrote on last edited by
          #4

          You can only use url rewriting in the ASP.NET code if the request is handled by the ASP.NET engine. When you run it locally all requests are handled by the ASP.NET engine, but not on the server. Change the url to one that is handled by the ASP.NET engine, change which extensions are handled by the ASP.NET engine, or use a url rewriting component.

          Despite everything, the person most likely to be fooling you next is yourself.

          I 1 Reply Last reply
          0
          • G Guffa

            You can only use url rewriting in the ASP.NET code if the request is handled by the ASP.NET engine. When you run it locally all requests are handled by the ASP.NET engine, but not on the server. Change the url to one that is handled by the ASP.NET engine, change which extensions are handled by the ASP.NET engine, or use a url rewriting component.

            Despite everything, the person most likely to be fooling you next is yourself.

            I Offline
            I Offline
            icanmakeiteasy
            wrote on last edited by
            #5

            thx for reply ... then let me know how to use url rewriting component

            icanmakeiteasy

            G 1 Reply Last reply
            0
            • I icanmakeiteasy

              thx for reply ... then let me know how to use url rewriting component

              icanmakeiteasy

              G Offline
              G Offline
              Guffa
              wrote on last edited by
              #6

              That depends entirely on what component you choose. Instructions for installation and usage will be included with the component.

              Despite everything, the person most likely to be fooling you next is yourself.

              1 Reply Last reply
              0
              • G Guffa

                When you say that it's "not working", what do you mean? What happens, and how does that differ from what you expect? Do you get any error message?

                Despite everything, the person most likely to be fooling you next is yourself.

                J Offline
                J Offline
                J4amieC
                wrote on last edited by
                #7

                Im having almost exactly the same issue as this OP. Ive developed a url rewriting "component" of sorts which uses the same method as this poster has decribed HttpContext.RewriteUrl method. When developed on my local machine with the VS web server its working fine. When I upload to Win 2008 Server all that happens is a 404. Its one of those rare cases where "not working" is about as much as you have to go on :| My solution will be to add lots of tracing to the code and enable it on the liove server to determine what is going wrong.

                N 1 Reply Last reply
                0
                • J J4amieC

                  Im having almost exactly the same issue as this OP. Ive developed a url rewriting "component" of sorts which uses the same method as this poster has decribed HttpContext.RewriteUrl method. When developed on my local machine with the VS web server its working fine. When I upload to Win 2008 Server all that happens is a 404. Its one of those rare cases where "not working" is about as much as you have to go on :| My solution will be to add lots of tracing to the code and enable it on the liove server to determine what is going wrong.

                  N Offline
                  N Offline
                  N a v a n e e t h
                  wrote on last edited by
                  #8

                  Have you sorted it? Windows 2008 has IIS7.0, right? It needs HttpHandlers and Modules to be configured explicitly.

                  Navaneeth How to use google | Ask smart questions

                  J 1 Reply Last reply
                  0
                  • N N a v a n e e t h

                    Have you sorted it? Windows 2008 has IIS7.0, right? It needs HttpHandlers and Modules to be configured explicitly.

                    Navaneeth How to use google | Ask smart questions

                    J Offline
                    J Offline
                    J4amieC
                    wrote on last edited by
                    #9

                    No ive not sorted it, and ive not got to grips with the intricacy of win 2008 server yet. So thanks for the pointer...i'll check that out now!

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups