I have several sitemap providers(default, admin, etc) and run into a problem when I am using the admin provider. The root node always shows the home page of the default provider instead of the admin provider. Any ideas why and how this can be fixed?
<siteMap defaultProvider="default" enabled="true">
<providers>
<clear/>
<add name="default"
description="Default SiteMap provider."
type="BLL.CustomSiteMapProvider"
siteMapFile="~/Web.sitemap"
securityTrimmingEnabled="true" />
<add name="AdminXmlSiteMapProvider"
description="Admin SiteMap provider."
type="BLL.CustomSiteMapProvider"
siteMapFile="~/admin/admin.sitemap"
securityTrimmingEnabled="true" />
<add name="FooterXmlSiteMapProvider"
description="Footer SiteMap provider."
type="BLL.CustomSiteMapProvider"
siteMapFile="footer.sitemap"
securityTrimmingEnabled="true" />
</providers>
</siteMap>
Related
I am working on a legacy MVC3 application which uses Forms authentication and SQLMembership Provider for authorizing user access. It has the folowing configuration:
<authentication mode="Forms">
<forms loginUrl="~/Account/Login" timeout="2880" />
</authentication>
<membership>
<providers>
<clear />
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices" enablePasswordRetrieval="true" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="true" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="3" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/TimeSheets" passwordFormat="Clear" />
</providers>
</membership>
<profile inherits="Timesheets.Services.UserProfile">
<providers>
<clear />
<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/TimeSheets" />
</providers>
</profile>
<roleManager enabled="true">
<providers>
<clear />
<add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/TimeSheets" />
<add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/TimeSheets" />
</providers>
</roleManager>
If I create a new MVC application using Windows Authentication this configuration seems to be replaced with configuration like this:
<authentication mode="Windows" />
<authorization>
<deny users="?" />
</authorization>
I have tried just changing the configuration of the legacy MVC site to use this new authentication mode, but this fails to authenticate (I get an Error message "401.2.: Unauthorized: Logon failed due to server configuration.")
However the new web project runs and authenticates correctly (so it's not an AD or local permissions issue)
I had thought to try just putting all the legacy code into the new project but it is rather large and complex and getting everything lined up again in the new site could be very time consuming.
I'm hoping that changing the Auth model should be simpler and less intrusive - But what additional steps would I need to perform to configure the legacy site for Windows Authentication?
The missing part of my configuration change was in the .proj file. This is due to using the IIS Express within Visual Studio.
In order to get the Windows Auth to work in the IIS Express for debugging you need to configure it in the project settings:
The lines:
<IISExpressAnonymousAuthentication />
<IISExpressWindowsAuthentication />
Need to be replaced with:
<IISExpressAnonymousAuthentication>disabled</IISExpressAnonymousAuthentication>
<IISExpressWindowsAuthentication>enabled</IISExpressWindowsAuthentication>
I want to specify a cache validator for google font on IIS 8.5.
http://fonts.googleapis.com/css?family=Open+Sans:400,400italic,300,700,600
What I did on my web.config is below;
<staticContent>
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="10.00:00:00" />
</staticContent>
I also added caching by extension
<caching>
<profiles>
<add extension=".woff" policy="CacheForTimePeriod" kernelCachePolicy="DontCache" duration="23:59:00" />
<add extension=".ttf" policy="CacheForTimePeriod" kernelCachePolicy="DontCache" duration="23:59:00" />
<add extension=".gif" policy="CacheForTimePeriod" kernelCachePolicy="DontCache" duration="23:59:00" />
<add extension=".js" policy="CacheForTimePeriod" kernelCachePolicy="CacheUntilChange" duration="23:59:00" />
<add extension=".png" policy="CacheForTimePeriod" kernelCachePolicy="DontCache" duration="23:59:00" />
<add extension=".jpg" policy="CacheForTimePeriod" kernelCachePolicy="DontCache" duration="23:59:00" />
<add extension=".css" policy="CacheForTimePeriod" kernelCachePolicy="CacheUntilChange" duration="23:59:00" />
</profiles>
</caching>
But I am still not able to apply cache-validator for Google Font that I used. I am also tried to set an expire time to E.g. May 2030 for static content but Google PageSpeed didnt recognized that also. * I have managed to do it with .httaccess, and checked .htaccess topics on stackoverflow. *
You can apply a cache validor only for contents that your server sevrs not external content ;-).
Moreover it's a false positive because Google fonts have cache control directives:
https://redbot.org/?uri=http%3A%2F%2Ffonts.googleapis.com%2Fcss%3Ffamily%3DOpen%2BSans%3A400%2C800
For whatever reason, the site I was working on (after a bit of pause) begun screaming about an sql server connection for the asp.net membership. I'm using mysql without asp.net membership so it was weird. However just to be sure I've decided to remove anything related to it, including role providers.
I've added these to the web.config
<membership>
<providers>
<clear />
</providers>
</membership>
<roleManager enabled="false">
<providers>
<clear />
</providers>
</roleManager>
<profile enabled="false">
<providers>
<clear />
</providers>
</profile>
However, it still throws exception: "Configuration Error, Default Role Provider could not be found." . What can I do?
I think I found what was missing: I had to remove the RoleManager module also.
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<remove name="RoleManager" />
</modules>
</system.webServer>
Following the article shanselman i'm trying to use "System.Web.Providers" so you can use memberships, rules and profiles with Sql Server Compact.
I installed via Nuget, created a Users.sdf database and copied to the App_Data folder.
My Web.config was as follows:
<profile defaultProvider="DefaultProfileProvider">
<providers>
<clear />
<add
name="DefaultProfileProvider"
type="System.Web.Providers.DefaultProfileProvider"
connectionStringName="DefaultConnection"
applicationName="/" />
</providers>
</profile>
<membership defaultProvider="DefaultMembershipProvider">
<providers>
<clear />
<add connectionStringName="DefaultConnection" enablePasswordRetrieval="false"
enablePasswordReset="true" requiresQuestionAndAnswer="false"
requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6"
minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10"
applicationName="/" name="DefaultMembershipProvider" type="System.Web.Providers.DefaultMembershipProvider" />
</providers>
</membership>
<roleManager defaultProvider="DefaultRoleProvider">
<providers>
<clear />
<add connectionStringName="DefaultConnection" applicationName="/"
name="DefaultRoleProvider" type="System.Web.Providers.DefaultRoleProvider" />
</providers>
</roleManager>
<sessionState mode="Custom" customProvider="DefaultSessionProvider">
<providers>
<add
name="DefaultSessionProvider"
type="System.Web.Providers.DefaultSessionStateProvider"
connectionStringName="DefaultConnection"
applicationName="/" />
</providers>
</sessionState>
<connectionStrings>
<add name="Sql_CE" connectionString="Data Source=|DataDirectory|\Users.sdf;"
providerName="System.Data.SqlServerCe.4.0"/>
</connectionStrings>
I can not use "aspnet_regsql" because it generates the tables to a SQL Server based
The following error occurs when trying to access the "Web Site Administration Tool" on page security
There is a problem with your selected
data store. This can be caused by an
invalid server name or credentials, or
by insufficient permission. It can
also be caused by the role manager
feature not being enabled. Click the
button below to be redirected to a
page where you can choose a new data
store.
The following message may help in
diagnosing the problem: The
pre-application start initialization
method Start on type
WebMatrix.WebData.PreApplicationStartCode
threw an exception with the following
error message: This method cannot be
called during the application's
pre-start initialization stage.
First rename your connection string to DefaultConnection and remove the \ in front of Users.sdf like so:
<connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=|DataDirectory|Users.sdf;"
providerName="System.Data.SqlServerCe.4.0"/>
</connectionStrings>
You say that you
created a Users.sdf database
how? The Providers framework and SqlCe should do this for you. Try deleting the Users.sdf from the App_Data folder and try accessing the "Web Site Administration Tool" again. The provider engine should recreate it for you.
I am developing an application in MVC 3.
I installed this provider via Nuget .
Basically, it allows to use any part of memberships, rules and profiles with a .sdf (compact) database.
I need the "Web Site Administration Tool" use this provider. But I can not use it.
Already checked the web.config and everything is ok.
When I open the "Web Site Administration Tool" on the Security I click test (any provider) and the error happens.
The following images.
Error when clicking test
"Could not establish a connection to the database.
If you have not yet created the SQL Server database, exit the Web Site Administration tool, use the aspnet_regsql command-line utility to create and configure the database, and then return to this tool to set the provider."
Here part of my web.config
<authentication mode="Forms" />
<membership>
<providers>
<add
connectionStringName="SqlCeServices"
applicationName="/"
enablePasswordRetrieval="false"
enablePasswordReset="true"
requiresQuestionAndAnswer="false"
requiresUniqueEmail="true"
passwordFormat="Hashed"
writeExceptionsToEventLog="false"
name="SqlCeMembershipProvider"
type="ErikEJ.SqlCeMembershipProvider, ErikEJ.SqlCeMembership" />
</providers>
</membership>
<profile enabled="false">
<providers>
<clear />
<add
name="SqlCeProfileProvider"
type="ErikEJ.SqlCeProfileProvider"
connectionStringName="SqlCeServices"
applicationName="/" />
</providers>
</profile>
<roleManager>
<providers>
<add
connectionStringName="SqlCeServices"
applicationName="/"
writeExceptionsToEventLog="false"
name="SqlCeRoleProvider"
type="ErikEJ.SqlCeRoleProvider, ErikEJ.SqlCeMembership" />
</providers>
</roleManager>
<connectionStrings>
<add name="SqlCeServices" connectionString="data source=|DataDirectory|\SqlCeAspnetdb.sdf" />
</connectionStrings>
I did alittle research and found this forum post:
http://social.msdn.microsoft.com/Forums/is/sqlce/thread/8024acc3-8418-4891-875b-8626ce9ba376.
It seems that ASPNETDB.MDF doesnt support SQL Server Compact due to the reasons specified. Can you not use SQL Server Express?