Role Provider error in web.config - asp.net-mvc-3

My application is in Asp.Net MVC3, my application was running perfectly but all of a sudden i'm getting an error in my Web.Config in my role manager tag.
Below is my RoleManager tag of web.config
<roleManager defaultProvider="MASSIARoleProvider" enabled="true" cacheRolesInCookie="true">
<providers>
<clear />
<add name="MASSIARoleProvider" type="MASSIA.Helpers.MASSIARoleProvider, MASSIA" connectionStringName="MASSIAEntities" />
</providers>
</roleManager>
Below is the error i'm getting directly when i run my application:
[updated Error Image]
I have a file MASSIARoleProvider.cs in my solution in the directory Helper.
Below is Heirarchy of my RoleProvider file.
--> Massia --> Helpers --> MASSIARoleProvider.cs
My solution was executing perfectly but i'm getting this error all of a sudden.

<roleManager defaultProvider="MASSIARoleProvider" enabled="true" cacheRolesInCookie="true">
<providers>
<clear />
<add name="MASSIARoleProvider" type="MASSIA.Helpers.MASSIARoleProvider" connectionStringName="MASSIAEntities" />
</providers>
</roleManager>
Attemp 2:
Check for your MASSIARoleProvider file and see whether the Solution name and references used are perfectly correct.
Attempt 3:
The last and least recommended.
Create a new solution, if and only if your solution is in the beginning stage and try to reconfigure the RoleProvider. Once it solved the issue for me, I made a new solution, added the existing files to the news solution and executed the new solution and it executed perfectly. I did not made any change to the code, i just included the existing files from the old solution to the new one.

Related

MVC 4 installation resulting in Exception has been thrown by the target of an invocation

I have an MVC 3 application that uses a Custom Role provider.
public class MyRoleProvider : System.Web.Security.RoleProvider
I have this setup in the web.config as follows
<roleManager defaultProvider="MyRoleProvider" enabled="true" cacheRolesInCookie="true">
<providers>
<clear />
<add name="MyRoleProvider" type="Namespace.MyRoleProvider, NameSpace" connectionStringName="MembershipDBConnStrName" />
</providers>
</roleManager>
This was all working fine until, well I decided to install MVC 4 to playaround with it.
Now my mvc 3 app is not loading with a configuration error that points to my custom role provider
Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: Exception has been thrown by the target of an invocation.
Line 81: <providers>
Line 82: <clear />
Line 83: **<add name="MyRoleProvider" type="Namespace.MyRoleProvider, Namespace" connectionStringName="MembershipDBConnStrName" />**
Line 84: </providers>
Line 85: </roleManager>
Doing some reading I see some huge changes around membership (namely the simplemembership provider) but I am hoping there is a quick fix for my stuff to continue to work.
Try delete all constructors from "MyRoleProvider" class.

Running MiniProfiler with runAllManagedModulesForAllRequests set to false

Recently we upgraded to MiniProfiler version 2.0.1 from v1.7, and since then we have not been able to use it in our MVC3 website because when it tries to get its resources, it instead gets a 404.
An example resource call is:
/mini-profiler-resources/includes.js?v=tNlJPuyuHLy/d5LQjyDuRbWKa0weCpmO3xkO6MH4TtA=
In searching around, most people are suggesting that simply setting runAllManagedModulesForAllRequests should be set to true. For giggles, I went ahead and set it to true, and yes it did work. But that is not an acceptable answer.
How can I keep runAllManagedModulesForAllRequests=false and still use MiniProfiler v2?
I had the same issue - the resources being requested use "static" file extensions (such as .js) and therefore IIS wants to handle them using its static file handler.
Luckily all of the MiniProfiler resources are requested with the path mini-profiler-resources, so you can add the following to your web.config:
<system.webServer>
...
<handlers>
<add name="MiniProfiler" path="mini-profiler-resources/*" verb="*" type="System.Web.Routing.UrlRoutingModule" resourceType="Unspecified" preCondition="integratedMode" />
</handlers>
</system.webServer>
The entry above instructs IIS that any request for the mini-profiler-resources path to be routed through ASP.NET.
As David Duffet says in the comments in the accepted answer, you might also need to add the following entry to your web config. This worked for me:
<system.web>
<httpHandlers>
<add verb="*" type="System.Web.Routing.UrlRoutingModule" path="mini-profiler-resources/*"/>
</httpHandlers>
</system.web>
I had a similar issue and what I did to fix it was change the application pool to 'integrated' and then I added this new line below to my web.config and it then worked.
Here is what the complete web.config looks like now for mini-profiler.
<system.webServer>
<modules runAllManagedModulesForAllRequests="false" />
<validation validateIntegratedModeConfiguration="false"/> <!-- Here is the new line -->
<handlers>
<add name="MiniProfiler" verb="*" type="System.Web.Routing.UrlRoutingModule" path="mini-profiler-resources/*"/>
</handlers>
</system.webServer>

Configuring Lightspeed for use in MVC3 Web project

I have a question regarding using LightSpeed in a MVC3 Web application. I am creating a REST Api project where I want to use LightSpeed, but the official configuration guidelines are quite vague. The official documentation says that the following lines need to be added to the file web.config:
<configSections>
<section name="lightSpeedContexts"
type="Mindscape.LightSpeed.Configuration.LightSpeedConfigurationSection, Mindscape.LightSpeed" />
</configSections>
<lightSpeedContexts>
<add name="Test" />
</lightSpeedContexts>
<lightSpeedContexts>
<add name="Test" dataProvider="SQLite3" />
</lightSpeedContexts>
I tried adding following lines to the web.config in the root:
<configSections>
<section name="lightSpeedContexts"
type="Mindscape.LightSpeed.Configuration.LightSpeedConfigurationSection, Mindscape.LightSpeed" />
</configSections>
<lightSpeedContexts>
<add name="Default" connectionStringName="Prod" dataProvider="MySQL5" />
</lightSpeedContexts>
<connectionStrings>
<add name="Prod" connectionString="server=localhost;User Id=production;password=xxx;Persist Security Info=True;database=CBS"/>
</connectionStrings>
This throws an exception when I start the Web application which tells me that configSections may not be specified more than once in the application. The root web.config file did not have any of these specified per default.
I am not sure where to put this configuration.
OK, I found out how to solve the problem.
I moved out the configSections that were in the two sub web.config files (in each Views folder) and put the contents in the main web.config file, then I added the lightSpeedContexts and connectionStrings in the main web.config file.

Asp.net Web Site Administration Tool with SqlCeMembership

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?

Windows Azure: asp.net <appsetting> for ChatHttpHandler not found

I have a problem in setting the chartHttpHandler in web.config for windows azure
Initially I added a chartHttpHandler on my web.config file
<remove name="ChartImageHandler"/>
<add name="ChartImageHandler" preCondition="integratedMode" verb="GET,HEAD" path="ChartImg.axd" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
under system.webServer section
Then I got an error stating
Invalid temp directory in chart handler configuration [c:\TempImageFiles\].
Then I found that I should change in
From
<add key="ChartImageHandler" value="storage=file;timeout=20;dir=c:\TempImageFiles\;" />
To
<add key="ChartImageHandler" value="storage=file;timeout=20;" />
I am not able to find this section in my web.config file. So I tried to add it under section but it gave me error that it is an invalid child
Likewise, I tried adding it under section, it too gave the same error...
So, I added sepeartely, Then I am not able to see anything.. The webpage is just blank...
What should I have to do.. Can anyone tell me "how to solve it"
Looks like you need to add it in appSettings... http://blogs.msdn.com/deliant/archive/2008/12/02/managing-chart-generated-images-with-chart-image-handler.aspx
(No personal knowledge about this, but that's the first link I found via Bing.)

Resources