在asp.net中实现URL重写的问题 [英] Problem implementing URL rewriting in asp.net

查看:47
本文介绍了在asp.net中实现URL重写的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在我的项目中实现URL重写我想要我的网址:

http:// localhost :54611 / WebSite6 / Customer.aspx [ ^ ]



看起来像:

http: // localhost:54611 / WebSite6 / Customer [ ^ ]



我将Intelligencia.UrlRewriter.dll添加到我的bin文件夹。



我添加了以下内容在我的web.config文件中编写代码。



 <  < span class =code-leadattribute> configuration  >  
< configSections >
< 部分 < span class =code-attribute> name = rewriter requirePermission = false type = Intelligencia.UrlRewriter.Configuration.RewriterConfigurationSectionHandler,Intelligencia.UrlRewriter / >
< / configSections >
< connectionStrings >
< add 名称 = ApplicationServices connectionString = data source = .\SQLEXPRESS; Integrated Security = SSPI; AttachDBFilename = | DataDirectory | \ aspnetdb.mdf; User Instance = true providerName = 系统.Data.SqlClient / >
< / connectionStrings >
&升t; system.web >
< httpModules >
< add name = UrlRewriter type = Intelligencia.UrlRewriter.RewriterHttpModule,Intelligencia.UrlRewriter / >

< / httpModules >
< 编译 debug = true targetFramework = 4.0 / >
< 身份验证 mode = 表格 >
< 表格 loginUrl = 〜/ Account / Login.aspx 超时 = 2880 / >
< ; / authentication >
< 成员资格 >
< 提供商 >
< clear / >
< add 名称 = AspNetSqlMembershipProvider type = System.Web.Security.SqlMembershipProvider connectionStringName = ApplicationServices enablePasswordRetrieval = false enablePasswordReset = true requiresQuestionAndAnswer = false requiresUniqueEmail = false maxInvalidPasswordAttempts = 5 minRequiredPasswordLength = 6 minRequiredNonalphanumericCharacters = 0 passwordAttemptWindow = 10 applicationName = / / <跨度class =code-keyword>>
< / providers >
< / membership >
< profile >
< 提供商 >
< clear / >
< 添加 名称 = AspNetSqlProfile提供商 类型 = System.Web.Profile.SqlProfileProvider connectionStringName = ApplicationServices applicationName = / / >
< / providers >
< / profile >
< roleManager 已启用 = false >
< < span class =code-leadattribute>提供商
>
< clear / >
< add name = AspNetSqlRoleProvider type = System.Web.Security.SqlRoleProvider connectionStringName = ApplicationServices applicationName = / / >
< add name = AspNetWindowsTokenRoleProvider type = System.Web.Security.WindowsTokenRoleProvider applicationName = / / >
< / providers >
< / roleManager >
< / system.web >
< system.webServer >
< 处理程序 >
< 删除 name = Exten sionlessUrl-Integrated-4.0 / >
< / handlers >
< modules runAllManagedModulesForAllRequests = true > ;

< add name = UrlRewriter type = Intelligencia.UrlRewriter.RewriterHttpModule / >
< ; / modules >
< 验证 validateIntegratedModeConfiguration = false / >
< / system.webServer >

< 重写者 >
< 重写 url = 〜/ Customer $ = 〜/ Customer.aspx ignoreCase = true / >
< / rewriter >


< / configuration >





I我没有收到任何错误。但是我无法从我的页面中删除.aspx扩展名。

解决方案

to = 〜/ Customer.aspx ignoreCase = true / >
< /重写者 >


< < span class =code-leadattribute> / configuration >





我没有收到任何错误。但是我无法从我的页面中删除.aspx扩展名。


 <  重写器 >  
< 重写 url = 〜/ Customer


to = 〜/ Customer.aspx ignoreCase < span class =code-keyword> = true / >
< / rewriter >







更改为

 <  重写 >  
< 重写 to = 〜/客户

I am implementing URL rewriting in my project werein i want my URL:
http://localhost:54611/WebSite6/Customer.aspx[^]

to look like:
http://localhost:54611/WebSite6/Customer[^]

I added Intelligencia.UrlRewriter.dll to my bin folder.

And i added the below written code in my web.config file.

<configuration>
  <configSections>
    <section name="rewriter" requirePermission="false" type="Intelligencia.UrlRewriter.Configuration.RewriterConfigurationSectionHandler, Intelligencia.UrlRewriter"/>
  </configSections>
    <connectionStrings>
        <add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient"/>
    </connectionStrings>
    <system.web>
    <httpModules>
      <add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule, Intelligencia.UrlRewriter"/>

    </httpModules>
    <compilation debug="true" targetFramework="4.0"/>
        <authentication mode="Forms">
            <forms loginUrl="~/Account/Login.aspx" timeout="2880"/>
        </authentication>
        <membership>
            <providers>
                <clear/>
                <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/"/>
            </providers>
        </membership>
        <profile>
            <providers>
                <clear/>
                <add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/"/>
            </providers>
        </profile>
        <roleManager enabled="false">
            <providers>
                <clear/>
                <add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/"/>
                <add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/"/>
            </providers>
        </roleManager>
    </system.web>
    <system.webServer>
    <handlers>
      <remove name="ExtensionlessUrl-Integrated-4.0"/>
    </handlers>
    <modules runAllManagedModulesForAllRequests="true">

      <add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule"/>
    </modules>
    <validation validateIntegratedModeConfiguration="false"/>
    </system.webServer>

  <rewriter>
    <rewrite url="~/Customer$" to="~/Customer.aspx" ignoreCase="true" />
  </rewriter>


</configuration>



I am not getting any errors.But i am not able to remove the .aspx extension from my page.

解决方案

" to="~/Customer.aspx" ignoreCase="true" /> </rewriter> </configuration>



I am not getting any errors.But i am not able to remove the .aspx extension from my page.


<rewriter>
   <rewrite url="~/Customer


" to="~/Customer.aspx" ignoreCase="true" /> </rewriter>




change to

<rewriter>
   <rewrite to="~/Customer


这篇关于在asp.net中实现URL重写的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆