I'm writting Simple Membership and Role Provider.
I'm trying run the code from post http://www.brianlegg.com/post/2011/05/09/Implementing-your-own-RoleProvider-and-MembershipProvider-in-MVC-3.aspx but on run IIS show me error:
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.
Line 39: <providers>
Line 40: <clear />
Line 41: <add name="LocalBankMembershipProvider" type="LocalBank.Helpers.LocalBankMembershipProvider, LocalBank" connectionStringName="LocalBankEntities" />
Line 42: </providers>
Line 43: </membership>
Message Parser Error: Target call threw an exception.
Line: 41
Where I made a mistake at the start of the project?
Convert project using Nuget package from mvc3 to mvc4
how can I fix this error?
Did you followed advise given in comments section on the same link?
Few things to try:
It might be the connection string that is wrong and due to which you are seeing this error. Change the connection string (e.g. data source). If you still see an issue, debug the project and see where exactly it is stuck and what more information you can get. I was able to reproduce this issue and with changes in connection string it was solved.
When you debug you will see it will throw exception when it checks role exists. As per the blog, you need to add default role "Manager":
The only thing to note is there are no roles created. If you look inside the AccountController Register HttpPost action you'll notice that any user who registers through this site is given a default role of "Member". This can be changed, but whatever role this is must first already be created in the Role table. You can do this by writing a script (most likely preferred method) or you can write some hacky code and call it real quick since it will only need to be ran 1 time when first creating roles. Here's some example code you can use to create the "Member" role, modify it to suit your needs.
LocalBankRepository repo = new LocalBankRepository();
repo.AddRole("Member");
repo.Save();
Call those 3 lines from somewhere in your code (or a separate
"initializer" project) and from then on the code should work as
expected. Sorry for the confusion.
If you still face issue share with more details. Hope this helps.
Related
I have a very weird problem.
I have a development environment where I develop a ASP.NET MVC Application, in this environment everything works. Especially in the Application there is a certain AJAX call which calls on a controller and passes data, the controller just needs to update the database with the passed information.Everything works!.
However I hop onto the server with everything setup just as development environment(database,connection strings all that). An everything works fine, login functions as well as other database saving functions and controller actions seems to work fine. Except for ONE controller that return a 500 Internal Server Error.
I asked around and everyone wants to see the logs.
In the event viewer there are no logs pertaining to this 500 Internal Server Error.
IIS logs however did provide something,but the information does not give specifics on what is causing the 500 Internal Server Error.
I know what a 500 Internal Server Error is and I know its a generic error for a variety of problems, however after looking at the logs I cannot figure out why this specific controller action is giving a 500 error when it is live on the production server BUT no problems when doing it in the development environment-very weird.
Browser Console
IIS Normal Logs
IIS Failed Request Tracing on 500
I had similar problem 2 weeks ago and also had posted about it in stackoverflow [asp.net web api: only during sql connection - HTTP 500 Error occurs : Local host is currently unable to handle request.
After hours of looking into the issue, it was figured out as a stored procedure missing in database.
Not sure whether it will help you with the problem, but hope it can give you some lead to resolve the problem.
Following #A.Roussos's advice to use Visual Studio debugging on the PRODUCTION SERVER (might seem obvious for me it wan't haha), I got some information.
My problem is that before I save data to the database I parse a string to double using the parse function.
Example
double a = Double.Parse(mystring);
The problem however is apparently the parse function is reliant on your regional settings(CultureInfo).
So I just added the following information to the code
double a = Double.Parse(mystring,System.Globalization.CultureInfo.InvariantCulture);
Something to note is that my application didn't crash when I got the 500 Internal Server Error, I didn't have a clue as to what could cause it.After using Visual Studio I got sufficient information to use and google and figure this thing out.
What killed me was that the application(or the one specific controller action in the application) worked perfectly on the development environment but not on the production environment, something like that has never happened to me and I am glad I got this learning experience.
Can you make sure that the URL which you are hitting doesn't has any whitespace in it?
Have the web.Config set to the custom errors mode as off. You should be able to see the full errors and any additional details associated with these.
Many times there are missing aspects in the environment that causes these errors.
It seems that the error is generated by a private method being called in the controller's action method but the error itself is getting eaten (empty catch) or just throw, causing an application failure. Check if the exception handler is present and logging the details somehow.
I am looking for a way to have different log path for different error types in my web api project. What I want is to put System.Web.HttpException errors in different folder and my other errors in a another folder. The reason for that is, I receive so many System.Web.HttpException errors which most of them are irrelevant but I still need to log them but in a different folder. My elmah setup is a standard one.
this is my web config tag:
<errorLog type="Elmah.XmlFileErrorLog, Elmah" logPath="~/App_Data/ErrorLog" />
<security allowRemoteAccess="false" />
</elmah>
any help is much appreciated.
The short answer: You can't. XmlFileErrorLog only supports a single directory as logPath.
If you want to implement this, you would need to fork the ELMAH source code and override the Log-method of XmlFileErrorLog.
Another approach could be to use ELMAH error filtering to ignore all System.Web.HttpException errors and then use another logging framework to log those errors. If you set up log4net, NLog, Serilog or similar, you could make that integration log all errors (including the HTTP exceptions).
I have web application developed using Asp.Net MVC 5.
I am integrated Elmah.MVC error logging library for error logging and reporting.
I got weird error messages
like the following:
System.Web.HttpException: The controller for path '/manager/html' was not found or does not implement IController.
The source of request was the following ip 221.194.44.229
which is in China.
Another message:
System.Web.HttpException: The controller for path '/888/pakistani-hackers-forcing-pilots-listen-pakistan-kashmir' was not found or does not implement IController.
The source of request was the following ip 39.45.204.204
which is in Pakistan.
I do not know if elmah.mvc is contains malware or such trojan or myserver was hacked how to investigate that issue and where is problems come from.
Do not know if that the correct place to ask such question or not
Mainly there is some one trying to request apath that is not on your site.
The idia is to make you read the massage in the requested path ( like the secound error from your post) that is som kind of spam.
There is nothing to worry about? This happened every day.
But i think you need to enable custom error pages if you are not already do.
The WSAT throws the following irrespective of the project or the connection type,
An error was encountered. Please
return to the previous page and try
again.
Even on a brand new ASP.NET MVC 2 website where user authentication and registration work through the default account controller without a quibble, the WSAT fails to run.
Things I've tried,
Tried to open it in IE.
Tried to use it with MySQL to setup
user authorization, role and profile
management. This was the goal which
is starting to seem more and more
like an uphill battle.
Tried it with a brand new ASP.NET
MVC 2 application.
Help would be greatly appreciated.
Found it. Apparently the configuration manager will not work if the directory path to the solution contains invalid characters, in my case it was a space.
Should be documented somewhere, this was a good waste of four hours..
Server Error in '/' Application.
Runtime Error
Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.
Details: To enable the details of this specific error message to be viewable on remote machines, please create a tag within a "web.config" configuration file located in the root directory of the current web application. This tag should then have its "mode" attribute set to "Off".
Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's configuration tag to point to a custom error page URL.
That is the default generic error message in ASP.NET.
Re the more specific "what kind of error"; impossible for us to say; it could be a configuration error in web.config, it could be problems talking to the database, it could simply need a hug and some quiet time. Like the message says, either enable remote debug output, or look at the site from the server, and it'll tell you what is actually happening. Or look in the error log (event-viewer by default), which is perhaps more useful.
Note you can replace the error page with something more... user friendly if you like. Like the lolcatz on stackoverflow.com.
Edit the web.config file to have this
<system.web>
<customErrors mode="RemoteOnly"/>
</system.web>