asp.net 配置不显示我的应用程序名称

发布于 2024-11-09 16:31:42 字数 2310 浏览 7 评论 0原文

我想在 asp.net 配置中设置我的 Web 应用程序的应用程序名称,但没有任何效果。它总是显示“应用程序:/”。我花了好几个小时来寻找答案。我确信这很简单(一如既往)。有人可以帮忙指出一下吗?

这是我的 web.config...

<configuration>
<connectionStrings>
    <clear />
    <add name="LocalSqlServer" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\AbetEvaluation.mdf;Integrated Security=True;User Instance=True"
 providerName="System.Data.SqlClient" />
    <add name="AbetConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\AbetEvaluation.mdf;Integrated Security=True;User Instance=True"
 providerName="System.Data.SqlClient" />
</connectionStrings>

<system.web>

    <compilation debug="true" targetFramework="4.0" />

    <authentication mode="Forms">
        <forms loginUrl="~/Login.aspx" />
    </authentication>

    <authorization>
        <allow users="*" />
    </authorization>

    <membership defaultProvider="AbetMembershipProvider">
        <providers>
            <clear />
            <add
     name="AbetMembershipProvider"
     type="System.Web.Security.SqlMembershipProvider"
     applicationName="/AbetEvaluation"
     connectionStringName="AbetConnectionString"
     requiresQuestionAndAnswer="false"
     minRequiredPasswordLength="6"
     minRequiredNonalphanumericCharacters="0"
     requiresUniqueEmail="true"
     passwordFormat="Clear"
     />
        </providers>
    </membership>

    <roleManager enabled="true" defaultProvider="AbetRoleProvider">
        <providers>
            <clear />
            <add
     name="AbetRoleProvider"
     type="System.Web.Security.SqlRoleProvider"
     connectionStringName="AbetConnectionString"
     applicationName="/AbetEvaluation"
     />
        </providers>
    </roleManager>

    <siteMap defaultProvider="XmlSiteMapProvider" enabled="true">
        <providers>
            <add
     name="XmlSiteMapProvider"
     description="Default SiteMap provider."
     type="System.Web.XmlSiteMapProvider"
     siteMapFile="Web.sitemap"
     securityTrimmingEnabled="true"
     />
        </providers>
    </siteMap>

</system.web>

I want to set the application name for my web app in the asp.net configuration, but nothing is working for me. It always says "Application:/". I have put quite a few hours into searching for an answer. I'm sure it's something simple (as it always is). Can someone help point it out?

Here's my web.config...

<configuration>
<connectionStrings>
    <clear />
    <add name="LocalSqlServer" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\AbetEvaluation.mdf;Integrated Security=True;User Instance=True"
 providerName="System.Data.SqlClient" />
    <add name="AbetConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\AbetEvaluation.mdf;Integrated Security=True;User Instance=True"
 providerName="System.Data.SqlClient" />
</connectionStrings>

<system.web>

    <compilation debug="true" targetFramework="4.0" />

    <authentication mode="Forms">
        <forms loginUrl="~/Login.aspx" />
    </authentication>

    <authorization>
        <allow users="*" />
    </authorization>

    <membership defaultProvider="AbetMembershipProvider">
        <providers>
            <clear />
            <add
     name="AbetMembershipProvider"
     type="System.Web.Security.SqlMembershipProvider"
     applicationName="/AbetEvaluation"
     connectionStringName="AbetConnectionString"
     requiresQuestionAndAnswer="false"
     minRequiredPasswordLength="6"
     minRequiredNonalphanumericCharacters="0"
     requiresUniqueEmail="true"
     passwordFormat="Clear"
     />
        </providers>
    </membership>

    <roleManager enabled="true" defaultProvider="AbetRoleProvider">
        <providers>
            <clear />
            <add
     name="AbetRoleProvider"
     type="System.Web.Security.SqlRoleProvider"
     connectionStringName="AbetConnectionString"
     applicationName="/AbetEvaluation"
     />
        </providers>
    </roleManager>

    <siteMap defaultProvider="XmlSiteMapProvider" enabled="true">
        <providers>
            <add
     name="XmlSiteMapProvider"
     description="Default SiteMap provider."
     type="System.Web.XmlSiteMapProvider"
     siteMapFile="Web.sitemap"
     securityTrimmingEnabled="true"
     />
        </providers>
    </siteMap>

</system.web>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

鯉魚旗 2024-11-16 16:31:42

允许配置 ASP.NET 成员资格、角色和配置文件的 ASP.NET 配置网站使用 ApplicationURL 查询字符串参数中的值来显示在网站上。 (即应用程序:/CoolApp)大多数人只有一个反斜杠字符。您可以通过将项目属性中的 Web 应用程序虚拟路径参数设置为除 / 之外的其他内容来更改此设置,无论您在那里放置什么,都将在查询字符串中使用。

  1. 始终在 web.config 中为您的角色提供程序设置 applicationName

    add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="mySecurityDB" applicationName="/CoolApp"/>

  2. 更改项目设置中的虚拟路径:参数

The ASP.NET Configuration website that allows configuration of ASP.NET Membership, Role and Profiles uses the value in the ApplicationURL query string parameter to display on the website. (ie. Application: /CoolApp) Most people with have only a backslash character. You can change this by setting the web applications Virtual Path parameter in the project properties to something other than /, whatever you put there will be used in the query string.

  1. Always set the applicationName in the web.config for your role providers

    add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="mySecurityDB" applicationName="/CoolApp"/>

  2. Change the Virtual path: parameter in your project settings

拥醉 2024-11-16 16:31:42

还必须更改虚拟路径,提供程序元素中的应用程序名称属性是不够的。

您可以通过在 Visual Studio 中打开项目的属性来更改虚拟路径,然后选择左侧的 Web 选项卡。然后在右侧窗格中选择“使用 Visual Studio 开发服务器”单选按钮,默认情况下未选择该单选按钮,只有这样您才能更改虚拟路径。默认值为“使用本地 IIS Web 服务器”,因此为 / 应用程序名称。

It is imperative to change the virtual path as well, the application name attribute in the provider elements is not enough.

The Virtual Path you can change by opening up the project's Properties in Visual Studio, then select the Web tab on the left. On the right pane thenselect the "Use Visual Studio Development Server" radiobutton which is NOT selected by default and only then you can alter the Virtual Path. The default is "Use Local IIS Web server" and therefore the / application name.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文