What are the steps required to set up elmah on an ASP.NET MVC 3 application?
nuget elmah
customize elmah (storage, etc)
handle HandleError
Is that all? Is step 3 still necessary after nuget?
Taken from : HOW TO SETUP ELMAH.MVC WITH ASP.NET MVC 4 ?
What is Elmah ?
ELMAH is an open source project whose purpose is to log and report unhandled exceptions in ASP.NET web applications.
Why to use Elmah ?
ELMAH serves as an unobtrusive interceptor of unhandled ASP.NET exceptions, those usually manifesting with the ASP.NET yellow screen of death.
So now we know what and why to use Elmah, Lets quickly get started on how to use Elmah with your ASP.NET MVC project.
Step 1: Right click on your solution and select the "Manage Nuget Packages" option
Step 2: In the Nuget Package manager search for "Elmah" and install the Elmah.MVC nuget extension.
The Nuget Package manager will download and add the required dlls and modify the web.config's <appSetting> for Elmah to work.
Step 3: That's it !! Your Elmah is now ready to test. I have generated a 404 to test if my Elmah works, ELMAH can be accessed by this url : http://yourapp.com/elmah.
Hope this helps :)
Further Reading :
Elmah on code.google.com
Elmah.MVC 2.0.2 on Nuget
Elmah.MVC on GitHub
I used ELMAH in 2010 and 2011. Now it is 2012, and I just added it to a new MVC 3 project and noticed the latest release made it much easier.
Nuget Elmah.mvc
URL is http://microsoft.com/admin/elmah
https://github.com/alexanderbeletsky/elmah.mvc/blob/master/README.md
http://www.beletsky.net/2011/03/integrating-elmah-to-aspnet-mvc-in.html
https://github.com/alexanderbeletsky/elmah.mvc
Is that all? Is step 3 still necessary
after nuget?
You should really set up a database table in MSSQL or another reliable DB to feed your errors into so they can be retrieved and stored reliably.
Otherwise no, there is no real config needed but you would likely use Email as well as block specific annoying errors.
After a quick google I found this: http://kurtschindler.net/blog/post/Configuring-ELMAH-on-DiscountASPNET
It turned out step 1 and 2 can be combined by nuget-ing "elmah on xml log", which will set up web.config so elmah will log errors into separate xml files. So no need to edit the config by hand at all, except to further customize elmah.
Step 3 is still necessary.
Elmah is already available for MVC
http://nuget.org/List/Packages/Elmah.MVC/1.2
basically, the hard bit is getting the Elmah config (in web.config) correct as the documentation is a little rough in my eyes
Related
In previous version of ASP.NET MVC 5, when you start project using Ctrl+F5, the route of current working file in vs will set to browser for example:
when you're editing about.cshtml from home controller and you start project, the browser will come up with localhost/home/about route.
I've tried checking configs of an mvc5 project but just found nothing.
My question is: how can I config the ASP.NET Core MVC project to behave like this?
Thanks
Update:
I found this stack that is near to my question, In my case I need "current page" option in ASP.NET Core
This feature is applicable in asp.net core project.
Workaround
If you need this, you can set launch url like below:
It same as add launch url in launchSettings.json.
I would like to add the following to Web.config of a Web api created in asp.net 5.
modules runAllManagedModulesForAllRequests="true"
This was working fine in my Web api which was not asp.net 5. In asp.net where to add this?
Any help greatly appreciated.
Thanks.
There is no more web.config in ASP.NET 5.
In fact there is no more modules. The old pipeline is no more. To be honest... it look similar but it's not the same framework as before.
I would highly recommend that you start by reading a bit on the new framework.
There's also a series that's called ASP.NET Monsters that deep dive into it. You should take a look since it looks you are starting from scratch.
When trying to deploy a new web api project which is created from the web api template it fails with the following message:
Build failed: Build contains no websites or background workers
Are mvc 4 web api project supported yet? Or do I have to create a regular MVC 3 app and include the web api stuff manually through nuget to get it working?
Ok, so this was a stupid mistake by me but I'll keep the question here if someone run into the same issue. The problem was as simple as I forgot to turn on nuget package restore. Since I don't check in my packages I need to download them on install.
What is the best way to log an exception and give the user the error code that was logged. Along with this how are 404 errors handled. I have seen many solutions for both but not together in a way that fits nicely with the mvc model. Do you have an example too? Also for 404's is there a way to get the 404 even if the user hasn't logged in to the app?
Is elmah something that should be used in production?
Is there a nuget package that people suggest using?
Yes, use elmah, but make sure that access to the log viewer is controlled.
The package is Elmah.MVC, and make sure you read these:
http://www.hanselman.com/blog/ELMAHErrorLoggingModulesAndHandlersForASPNETAndMVCToo.aspx
http://dotnetdarren.wordpress.com/2010/07/27/logging-on-mvc-part-1/
Once deployed parts of my web-application stop working. Index-es on each controller do work, and one form posting via Ajax, Login works too. Other then that yields 404. I understand that nothing particular should be done in integrated mode.
I don't know how to proceed with troubleshooting.
Some info:
App is using default app pool set to integrated mode.
WebApp is done in net framework 3.5.
I use default routing model.
OS is Windows Server 2008.
IIS 7
Any help is appreciated. Thx.
EDIT:
I determined that only actions that accept ID parameter don't work. On the contrary, when I add dummy id method in Home controller of default MVC app it works.
EDIT 2:
I found the problem. Links on few pages of the site didn't use ActionLink helper. It was harder to see because of the Ajax invoking. So, never hardcode links to the actions on the site, even temporary.
Please go through this link for details on deploying MVC application with IIS 7 integrated mode.
http://www.asp.net/mvc/tutorials/older-versions/deployment/using-asp-net-mvc-with-different-versions-of-iis-cs