Question

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>

Était-ce utile?

La solution

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

Autres conseils

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.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top