In an ASP.Net MVC app there is a web.config in the root directory, the views folder, and the area folder. I have declared a namespace in my root web.config but any views in the views or area folder are not picking it up unless I add it to that fold's respective web.config file. Is there a way to enable inheritance from the root to sub folder web.configs so what ever settings I place in the root web.config are seen in both the area and view folders?
Root Web.Config:
<system.web>
<httpRuntime targetFramework="4.5" />
<compilation debug="true" targetFramework="4.5" />
<customErrors mode="RemoteOnly">
<error statusCode="404" redirect="~/404.aspx" />
</customErrors>
<pages>
<namespaces>
<add namespace="System.Web.Helpers" />
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
<add namespace="System.Web.WebPages" />
<add namespace="System.Web.Optimization" />
</namespaces>
</pages>
<httpModules>
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" />
<add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" />
<add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" />
</httpModules>
</system.web>
Views Folder web.config:
<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="System.Web.Mvc.WebViewPage">
<namespaces>
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
</namespaces>
</pages>
</system.web.webPages.razor>
In addition to the code given by Andrew Barber I had to add
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
</sectionGroup>
I'm setting up a mixed ASP.NET MVC / ASP.NET site (based on Kentico, if that matters) and having issues:
[ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index]
System.ThrowHelper.ThrowArgumentOutOfRangeException() +72
System.Collections.ObjectModel.Collection`1.set_Item(Int32 index, T value) +10419142
Telerik.Web.Mvc.UI.HtmlHelperExtension.Telerik(HtmlHelper`1 helper) in f:\115\Griffin\Current Full\Sources\Source\Telerik.Web.Mvc\UI\HtmlHelperExtension.cs:57
ASP._Page_Views_Shared__Layout_cshtml.Execute() in c:\temp\air-vend\Views\Shared\_Layout.cshtml:6
I found this document and I believe I've gone through that correctly - I've redone it now 3 times, but I'm obviously still missing something.
Anyone have any ideas? What could I post to help figure it out?
Here are the relevant parts of the web.config:
<?xml version="1.0"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<configSections>
<!-- Content staging BEGIN -->
<section name="microsoft.web.services3" type="Microsoft.Web.Services3.Configuration.WebServicesConfiguration, Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<!-- Content staging END -->
<sectionGroup name="telerik">
<section name="webAssets" type="Telerik.Web.Mvc.Configuration.WebAssetConfigurationSection, Telerik.Web.Mvc" requirePermission="false" />
</sectionGroup>
</configSections>
<appSettings>
</appSettings>
<telerik>
<webAssets useTelerikContentDeliveryNetwork="true" />
</telerik>
<connectionStrings>
<clear/>
</connectionStrings>
<system.web>
<pages validateRequest="false" clientIDMode="AutoID">
<controls>
<add tagPrefix="ajaxToolkit" namespace="AjaxControlToolkit" assembly="AjaxControlToolkit"/>
<add tagPrefix="cms" namespace="CMS.Controls" assembly="CMS.Controls"/>
<add tagPrefix="cms" namespace="CMS.FormEngine" assembly="CMS.FormEngine"/>
<add tagPrefix="cms" namespace="CMS.FormControls" assembly="CMS.FormControls"/>
<add tagPrefix="cms" namespace="CMS.ExtendedControls" assembly="CMS.ExtendedControls"/>
<add tagPrefix="cms" namespace="CMS.PortalControls" assembly="CMS.PortalControls"/>
<add tagPrefix="asp" namespace="System.Web.UI.DataVisualization.Charting" assembly="System.Web.DataVisualization"/>
</controls>
<namespaces>
<add namespace="System.Web.Http"/>
<add namespace="System.Web.Mvc"/>
<add namespace="System.Web.Mvc.Ajax"/>
<add namespace="System.Web.Mvc.Html"/>
<add namespace="System.Web.Routing"/>
<add namespace="CMS.CMSHelper"/>
<add namespace="CMS.GlobalHelper"/>
<add namespace="Telerik.Web.Mvc.UI" />
<add namespace="Telerik.Reporting" />
<add namespace="Telerik.ReportViewer.WebForms" />
</namespaces>
</pages>
<customErrors defaultRedirect="~/CMSMessages/error.aspx" mode="Off">
<error statusCode="404" redirect="~/CMSMessages/PageNotFound.aspx"/>
</customErrors>
<authentication mode="Forms">
<forms loginUrl="CMSPages/logon.aspx" defaultUrl="Default.aspx" name=".ASPXFORMSAUTH" timeout="60000" slidingExpiration="true"/>
</authentication>
<httpRuntime maxRequestLength="2097151" waitChangeNotification="1" maxWaitChangeNotification="3600" requestValidationMode="2.0" maxUrlLength="1000"/>
<globalization requestEncoding="utf-8" responseEncoding="utf-8" culture="en-US" uiCulture="en-US"/>
<membership defaultProvider="CMSProvider" userIsOnlineTimeWindow="30">
<providers>
<clear/>
<add name="CMSProvider" type="CMS.MembershipProvider.CMSMembershipProvider" connectionStringName="CMSConnectionString" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="true" passwordFormat="Hashed"/>
</providers>
</membership>
<roleManager defaultProvider="CMSRoleProvider" enabled="true" cacheRolesInCookie="true" cookieName=".ASPROLES" cookieTimeout="30" cookiePath="/" cookieRequireSSL="false" cookieSlidingExpiration="true" cookieProtection="All">
<providers>
<clear/>
<add name="CMSRoleProvider" type="CMS.MembershipProvider.CMSRoleProvider" connectionStringName="CMSConnectionString" applicationName="SampleApplication" writeExceptionsToEventLog="false"/>
</providers>
</roleManager>
<httpHandlers>
<add path="ChartImg.axd" verb="*" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
<add verb="GET,HEAD" path="asset.axd" validate="false" type="Telerik.Web.Mvc.WebAssetHttpHandler, Telerik.Web.Mvc" />
<add type="Telerik.ReportViewer.WebForms.HttpHandler, Telerik.ReportViewer.WebForms, Version=6.1.12.611, Culture=neutral, PublicKeyToken=a9d7983dfcc261be" path="Telerik.ReportViewer.axd" verb="*" validate="true" />
</httpHandlers>
<httpModules>
<add name="XHtmlModule" type="CMS.CMSOutputFilter.OutputFilterModule, CMS.OutputFilter"/>
<add name="CMSApplicationModule" type="CMS.CMSHelper.CMSApplicationModule, CMS.CMSHelper"/>
</httpModules>
<xhtmlConformance mode="Strict"/>
<sessionState mode="InProc" stateConnectionString="tcpip=127.0.0.1:42424" sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes" cookieless="false" timeout="20"/>
<compilation debug="true" numRecompilesBeforeAppRestart="100" targetFramework="4.0">
<assemblies>
<add assembly="SMDiagnostics, Version=3.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="Microsoft.Transactions.Bridge, Version=3.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Management, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Configuration.Install, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.DirectoryServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Web.Extensions.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Deployment, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Transactions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Web.RegularExpressions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Messaging, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.IdentityModel.Selectors, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.ServiceProcess, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Data.Entity.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.WebPages, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="Telerik.Web.Mvc" />
</assemblies>
<!-- Different programming languages BEGIN -->
<!--
<codeSubDirectories>
<add directoryName="CSCode"></add>
<add directoryName="VBCode"></add>
</codeSubDirectories>
-->
<!-- Different programming languages END -->
</compilation>
<httpCookies httpOnlyCookies="true"/>
</system.web>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<!-- Windows authentication BEGIN -->
<!--
<location path="">
<system.web>
<authorization>
<deny users="?"/>
</authorization>
</system.web>
</location>
-->
<!-- Windows authentication END -->
<location path="cms">
<system.web>
<authorization>
<deny users="?"/>
</authorization>
</system.web>
</location>
<!-- WebDAV location BEGIN -->
<location path="cms/files">
<system.web>
<httpHandlers>
<clear/>
<add verb="*" path="*" type="CMS.WebDAV.WebDAVHandler, CMS.WebDAV"/>
</httpHandlers>
<httpRuntime executionTimeout="2400" maxRequestLength="2097151"/>
</system.web>
<system.webServer>
<handlers>
<clear/>
<add name="CMSWebDAVHandler" path="*" verb="*" type="CMS.WebDAV.WebDAVHandler, CMS.WebDAV"/>
<remove name="xoml-Integrated"/>
<add name="*.vbhtml_*" preCondition="integratedMode,runtimeVersionv2.0" verb="*" path="*.vbhtml" type="System.Web.HttpForbiddenHandler"/>
<add name="*.vbhtm_*" preCondition="integratedMode,runtimeVersionv2.0" verb="*" path="*.vbhtm" type="System.Web.HttpForbiddenHandler"/>
<add name="*.cshtml_*" preCondition="integratedMode,runtimeVersionv2.0" verb="*" path="*.cshtml" type="System.Web.HttpForbiddenHandler"/>
<add name="*.cshtm_*" preCondition="integratedMode,runtimeVersionv2.0" verb="*" path="*.cshtm" type="System.Web.HttpForbiddenHandler"/>
<add name="*.xamlx_*" preCondition="integratedMode,runtimeVersionv2.0" verb="*" path="*.xamlx" type="System.Xaml.Hosting.XamlHttpHandlerFactory, System.Xaml.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add name="*.xoml_*" preCondition="integratedMode,runtimeVersionv2.0" verb="*" path="*.xoml" type="System.ServiceModel.Activation.HttpHandler, System.ServiceModel.Activation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add name="*.svc_*" preCondition="integratedMode,runtimeVersionv2.0" verb="*" path="*.svc" type="System.ServiceModel.Activation.HttpHandler, System.ServiceModel.Activation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add name="*.soap_*" preCondition="integratedMode,runtimeVersionv2.0" verb="*" path="*.soap" type="System.Runtime.Remoting.Channels.Http.HttpRemotingHandlerFactory, System.Runtime.Remoting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<add name="*.rem_*" preCondition="integratedMode,runtimeVersionv2.0" verb="*" path="*.rem" type="System.Runtime.Remoting.Channels.Http.HttpRemotingHandlerFactory, System.Runtime.Remoting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<add name="*.asmx_*" preCondition="integratedMode,runtimeVersionv2.0" verb="*" path="*.asmx" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add name="ScriptResource.axd" preCondition="integratedMode,runtimeVersionv2.0" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add name="*_AppService.axd_*" preCondition="integratedMode,runtimeVersionv2.0" verb="*" path="*_AppService.axd" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add name="eurl.axd_*" preCondition="integratedMode,runtimeVersionv2.0" verb="*" path="eurl.axd" type="System.Web.HttpNotFoundHandler"/>
</handlers>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="2147483648"/>
</requestFiltering>
</security>
<validation validateIntegratedModeConfiguration="false"/>
</system.webServer>
</location>
<!-- WebDAV location END -->
<!-- Content staging BEGIN -->
<microsoft.web.services3>
<security>
<securityTokenManager>
<add type="CMS.Synchronization.WebServiceAuthorization" namespace="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" localName="UsernameToken"/>
</securityTokenManager>
<x509 allowTestRoot="true" verifyTrust="true"/>
</security>
<policy fileName="wse3policy.config"/>
<diagnostics>
<trace enabled="false" input="InputTrace.webinfo" output="OutputTrace.webinfo"/>
</diagnostics>
</microsoft.web.services3>
<!-- Content staging END -->
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" >
<remove name="WebDAVModule"/>
<remove name="XHtmlModule"/>
<remove name="CMSApplicationModule"/>
<remove name="UrlRoutingModule"/>
<add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule,System.Web.Routing, Version=3.5.0.0,Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add name="XHtmlModule" type="CMS.CMSOutputFilter.OutputFilterModule, CMS.OutputFilter"/>
<add name="CMSApplicationModule" preCondition="managedHandler" type="CMS.CMSHelper.CMSApplicationModule, CMS.CMSHelper"/>
<add name="ErrorHandlerModule" preCondition="managedHandler" type="System.Web.Mobile.ErrorHandlerModule, System.Web.Mobile, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
</modules>
<handlers>
<remove name="asset" />
<add name="asset" preCondition="integratedMode" verb="GET,HEAD" path="asset.axd" type="Telerik.Web.Mvc.WebAssetHttpHandler, Telerik.Web.Mvc" />
<add name="Telerik.ReportViewer.axd_*" type="Telerik.ReportViewer.WebForms.HttpHandler, Telerik.ReportViewer.WebForms, Version=6.1.12.611, Culture=neutral, PublicKeyToken=a9d7983dfcc261be" path="Telerik.ReportViewer.axd" verb="*" preCondition="integratedMode" />
<remove name="MetaWeblogAPI"/>
<remove name="UrlRoutingHandler"/>
<add name="MetaWeblogAPI" preCondition="integratedMode" verb="*" path="MetaWeblog.ashx" type="CMS.MetaWeblogProvider.MetaWeblogAPI, CMS.MetaWeblogProvider"/>
<add name="ChartImageHandler" preCondition="integratedMode" verb="*" path="ChartImg.axd" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add name="UrlRoutingHandler" preCondition="integratedMode" verb="*" path="UrlRouting.axd" type="System.Web.HttpForbiddenHandler, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
</handlers>
<validation validateIntegratedModeConfiguration="false"/>
<httpErrors>
<remove statusCode="405" subStatusCode="-1"/>
<remove statusCode="404" subStatusCode="-1"/>
<error statusCode="404" prefixLanguageFilePath="" path="/CMSPages/handler404.aspx" responseMode="ExecuteURL"/>
<error statusCode="405" prefixLanguageFilePath="" path="/CMSPages/handler404.aspx" responseMode="ExecuteURL"/>
</httpErrors>
<rewrite>
<rules>
<rule name="www" enabled="false" stopProcessing="true">
<match url="(.*)"/>
<conditions>
<add input="{HTTP_HOST}" pattern="^www\.([.\x20-\x7E]+)$" negate="true"/>
<add input="{HTTP_HOST}" pattern="http://ht.io-web.com" negate="true"/>
</conditions>
<action type="Redirect" url="http://www.{HTTP_HOST}/{R:0}"/>
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
This is strange. Did you try to grab a sample project from here and see if there are any significant differences with your project? Comparing with a working project might help you trace the issue.
I am trying to add authentication to my application using the built in provider however I am getting an error doing so. My web.config file is as follows (with the db etc taken out of connection string but does all work):
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=152368
-->
<configuration>
<connectionStrings>
<add name="LaundryDBContext"
connectionString=".amazonaws.com,1433;
Initial Catalog=Main;
Persist Security Info=True;
User ID=****;
Password=****;
MultipleActiveResultSets=True"
providerName="System.Data.SqlClient"/>
</connectionStrings>
<appSettings>
<add key="webpages:Version" value="1.0.0.0"/>
<add key="ClientValidationEnabled" value="true"/>
<add key="UnobtrusiveJavaScriptEnabled" value="true"/>
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</assemblies>
</compilation>
<authentication mode="Forms">
<forms loginUrl="~/Account/LogOn" 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>
<pages>
<namespaces>
<add namespace="System.Web.Helpers" />
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
<add namespace="System.Web.WebPages"/>
</namespaces>
</pages>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
When trying to add authentication I am getting the following error:
The connection name 'ApplicationServices' was not found in the applications configuration or the connection string is empty.
I would love the authentication and application settings to be stored in the existing DB. how do I fix this?
The connectionStringName property of the provider entries are set to "ApplicationServices" which is not a named connection string in your web.config. Your connection string is named "LaundryDBContext".
Change the connnectionStringName property to "LaundryDBContext" and the provider will use that connection string to talk to your database.
You should read one of the many walkthroughs on configuring membership to understand how that works in more detail.
In brief...
open the visual studio command prompt and type aspnet_regsql
Follow the wizard in the dialog that opens to add the aspnet membership schema to your database.
I am developing an ASP.NET web-based application and I am using a Telerik tool with it. Everything works fine even in the production server in my company. Now, we have another server that we are using it for testing the web-based applications that we are developing. I copied my application including its database from the production server to this testing server, but it did not work well on it. it opens the website but there is no data from the database and I don't know why? I have the connectionstring in the web.config file and I have the same things that are in the production server but still there is no data.
I did not change anything in the application and I am using .NET 4 and it is installed in the both servers. Everything is the same but I don't know why I am getting this error. Do you have any solution to this problem?
Why the application works in the first server and does not work in the second one?
My web.config file is:
<configuration>
<connectionStrings>
<add connectionString="Data Source=localhost\sqlexpress;Initial Catalog=PMODServices;Integrated Security=True" name="PMODServicesConnectionString" providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
<customErrors mode="Off" />
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
<add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<add assembly="System.Speech, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Runtime.Serialization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<add assembly="System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<add assembly="System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<add assembly="System.Xml.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<add assembly="System.Data.DataSetExtensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<add assembly="Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
<add assembly="Microsoft.ReportViewer.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
<add assembly="Microsoft.Build.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
<add assembly="System.Management, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
<!-- <add assembly="office, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71E9BCE111E9429C"/> -->
<add assembly="stdole, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" /></assemblies>
<buildProviders>
<add extension=".rdlc" type="Microsoft.Reporting.RdlBuildProvider, Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</buildProviders>
</compilation>
<httpHandlers>
<!-- <add path="Telerik.Web.UI.WebResource.axd" verb="*" type="Telerik.Web.UI.WebResource" validate="false" />-->
<add path="Telerik.Web.UI.WebResource.axd" verb="*" type="Telerik.Web.UI.WebResource, Telerik.Web.UI" validate="false" />
<add path="ChartImage.axd" verb="*" type="Telerik.Web.UI.ChartHttpHandler" validate="false" />
<add path="Telerik.Web.UI.SpellCheckHandler.axd" verb="*" type="Telerik.Web.UI.SpellCheckHandler" validate="false" />
<add path="Telerik.Web.UI.DialogHandler.aspx" verb="*" type="Telerik.Web.UI.DialogHandler" validate="false" />
<add path="Telerik.RadUploadProgressHandler.ashx" verb="*" type="Telerik.Web.UI.RadUploadProgressHandler" validate="false" />
<add path="Reserved.ReportViewerWebControl.axd" verb="*" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" validate="false" />
</httpHandlers>
<authentication mode="Windows"/>
<pages>
<controls>
<add tagPrefix="telerik" namespace="Telerik.Web.UI" assembly="Telerik.Web.UI" />
</controls>
</pages>
<httpModules>
<add name="RadUploadModule" type="Telerik.Web.UI.RadUploadHttpModule" />
<add name="RadCompression" type="Telerik.Web.UI.RadCompression" />
</httpModules>
</system.web>
<location path="Users/Telerik.Web.UI.WebResource.axd">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>
<location path="Telerik.Web.UI.WebResource.axd">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<remove name="ChartImage_axd" />
<remove name="Telerik_Web_UI_SpellCheckHandler_axd" />
<remove name="Telerik_Web_UI_DialogHandler_aspx" />
<remove name="Telerik_RadUploadProgressHandler_ashx" />
<remove name="Telerik_Web_UI_WebResource_axd" />
<add name="Telerik_Web_UI_WebResource_axd" path="Telerik.Web.UI.WebResource.axd" type="Telerik.Web.UI.WebResource" verb="*" preCondition="integratedMode" />
<add name="ChartImage_axd" path="ChartImage.axd" type="Telerik.Web.UI.ChartHttpHandler" verb="*" preCondition="integratedMode" />
<add name="Telerik_Web_UI_SpellCheckHandler_axd" path="Telerik.Web.UI.SpellCheckHandler.axd" type="Telerik.Web.UI.SpellCheckHandler" verb="*" preCondition="integratedMode" />
<add name="Telerik_Web_UI_DialogHandler_aspx" path="Telerik.Web.UI.DialogHandler.aspx" type="Telerik.Web.UI.DialogHandler" verb="*" preCondition="integratedMode" />
<add name="Telerik_RadUploadProgressHandler_ashx" path="Telerik.RadUploadProgressHandler.ashx" type="Telerik.Web.UI.RadUploadProgressHandler" verb="*" preCondition="integratedMode" />
<add name="ReportViewerWebControlHandler" preCondition="integratedMode" verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</handlers>
<modules runAllManagedModulesForAllRequests="true">
<remove name="RadUploadModule" />
<remove name="RadCompression" />
<add name="RadUploadModule" type="Telerik.Web.UI.RadUploadHttpModule" preCondition="integratedMode" />
<add name="RadCompression" type="Telerik.Web.UI.RadCompression" preCondition="integratedMode" />
</modules>
</system.webServer>
<appSettings>
<add key="Telerik.ScriptManager.TelerikCdn" value="Enabled" />
<add key="Telerik.StyleSheetManager.TelerikCdn" value="Enabled" />
</appSettings>
</configuration>
Have you tried reinstalling telerik or putting the assemblies in GAC?As far as I remember , telerik needs more assemblies than you added in VS as reference to run properly.
I am creating a new application (webrole) in webforms called SGS. This application is being build using vb.net.
I am developing the app in windows 7 and have already deployed it to Windows azure.
Every time I need to change something in the application, I change it locally and then publish it again to my production enviroment (i know about staging enviroment in azure, but I prefered the production).
The app is in the start point, now I need to connect it to my database that is in SQL Azure.
I built a new database named SGS that is on SQL Azure and I want to connect my application to it.
I would like that even when I am in the local environment, my application only connects to my sql zure database. This way I don't need any database on my local Pc.
I don't know how to accomplish this.....
The connection string (ado.net) that is on the azure is :
Server=tcp:mwjw08qhju.database.windows.net,1433;Database=SGS;User ID=pr#mwjw08qhju;Password=myPassword;Trusted_Connection=False;Encrypt=True;
My webconfig file as this information:
<xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<system.diagnostics>
<trace>
<listeners>
<add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="AzureDiagnostics">
<filter type="" />
</add>
</listeners>
</trace>
</system.diagnostics>
<connectionStrings>
Server=tcp:mwjw08qhju.database.windows.net,1433;Database=SGS;User ID=pr#mwjw08qhju;Password=myPassword;Trusted_Connection=False;Encrypt=True;
<add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient" />
<!-- <add name="DefaultConnection" connectionString="Data Source=.\SQLEXPRESS;Initial
Catalog=aspnet_1db0ca8ec36d4ba1852e5e4ec9947660;Integrated Security=True;MultipleActiveResultSets=True" providerName="System.Data.SqlClient" />-->
<add name="DefaultConnection" connectionString=" <add name="DefaultConnection" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=aspnet_1db0ca8ec36d4ba1852e5e4ec9947660;Integrated Security=True;MultipleActiveResultSets=True" providerName="System.Data.SqlClient" />
<add name="aspnet_1db0ca8ec36d4ba1852e5e4ec9947660Entities" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SqlClient;provider connection string="data source=.\SQLEXPRESS;initial catalog=aspnet_1db0ca8ec36d4ba1852e5e4ec9947660;integrated security=True;multipleactiveresultsets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
<system.web>
<compilation debug="true" strict="false" explicit="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</assemblies>
</compilation>
<authentication mode="Forms">
<forms loginUrl="~/Account/Login.aspx" timeout="2880" />
</authentication>
<membership defaultProvider="DefaultMembershipProvider">
<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="/" />
<add name="DefaultMembershipProvider" type="System.Web.Providers.DefaultMembershipProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" />
</providers>
</membership>
<profile defaultProvider="DefaultProfileProvider">
<providers>
<clear />
<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/" />
<add name="DefaultProfileProvider" type="System.Web.Providers.DefaultProfileProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" applicationName="/" />
</providers>
</profile>
<roleManager enabled="false" defaultProvider="DefaultRoleProvider">
<providers>
<clear />
<add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/" />
<add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" />
<add name="DefaultRoleProvider" type="System.Web.Providers.DefaultRoleProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" applicationName="/" />
</providers>
</roleManager>
<sessionState mode="InProc" customProvider="DefaultSessionProvider">
<providers>
<add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" applicationName="/" />
</providers>
</sessionState>
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
</system.webServer>
</configuration>
What do I need to change to accomplish this?
Thank you very much.
This set up should do exactly what you want. It's only slightly more complex if you wanted to connect to SQL Server when running locally BUT SQL Azure when deployed.
To connect to SQL Azure from your local machine though, you'll need to have a firewall rule that allows traffic to reach SQL Azure. Ironically, the post right below yours in Stack Overflow has a response that should help you do this (if you haven't already).
If you set up the firewall rule and are still having issues, post back with more specifics about what's not working, error messages, etc.
Change the Service and Default connection strings to the connection string you received from the Azure SQL portal.
So you will get this:
<add name="ApplicationServices" connectionString="mwjw08qhju.database.windows.net,1433;Database=SGS;User ID=pr#mwjw08qhju;Password=myPassword;Trusted_Connection=False;Encrypt=True;" providerName="System.Data.SqlClient" />
Hope that helps