1

Greeting, pardon my maybe non important question, I am just trying to redecorate URLS that I am using in my Asp.net Web Forms application to be like Asp.net MVC apps that uses razor , the first step I've done is to remove the aspx successor and I am done with this but the second step is which I am trying is to replace pagename?id=someid with pagename/id or any formula except the usual formula , tbh the task eventually is to reduce the characters used in the ULR so removing .aspx will execlude 4 characters and the second approach will replace ?id= with slash and renaming page with pagename+id like n1 will not hit the server as the page name would have been changed any suggestion is welcome! I did the below change on my web.config to exclude aspx successor

<system.webServer>
        <rewrite>
            <rules>
                <rule name="RewriteASPX">
                    <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="{R:1}.aspx" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
Khalid
  • 343
  • 3
  • 16

1 Answers1

1

Update! I am able to find semi solution after few hours of searching and testing , I called it semi solution because ajax calls is no longer working , and any page that has update panel is showing error related to axd ,I used routing as the link below

ASP.NET Routing with Web Forms

just added the below code to global.asax file

protected void Application_Start(object sender, EventArgs e)
        {
            RegisterRoutes(RouteTable.Routes);
        }
        void RegisterRoutes(RouteCollection routes)
        {
               routes.MapPageRoute(
                "mypage",
                "mypage/{Name}",
                "~/mypage.aspx"
                                  );
         }

and on my page I am redirecting as:

Response.Redirect(GetRouteUrl("mypage", new { Name = "myparam" }));
Khalid
  • 343
  • 3
  • 16
  • the above solutions is working but if I have update panel , i have script manager error axd, Uncaught Error: ASP.NET Ajax client-side framework failed to load. – Khalid May 10 '21 at 00:18