Using ELMAH in medium trust - asp.net-mvc

I'm building an ASP.net mvc app, and am having some problems getting ELMAH deployed using xml logging to a medium trust server, though it works fine on my local machine. It keeps getting a 404 error.
The problem might be that the host doesn't allow relative filepaths, so the "~/App_Data" doesn't work for logging. I switched that to:
logPath="\\Something\Something\ID\www.website.com\web\content\App_Data"
in the web.config. The syntax might be completely off, but I've tried a few variations and none of them worked.
I subsequently found this question and added the recommended code to my web.config, but still no luck. Does anyone know how to get ELMAH to work on medium trust?
Thanks!

The asp.net worker process (or the aspnet user) has minimum rights to write into the filesystem. Try a place like c:\temp where everybody can write files. After this check and set access rights for aspnet user.

It turned out that the ELMAH.dll was calling SQLite, which isn't allowed under medium trust, and was causing ELMAH to fail when deployed to medium trust. I needed to download the source code for ELMAH and re-build it without the reference to SQLite. It is now working. Yay!

Related

Deploying ASP MVC 5 App with IIS 7.5

I try to deploy ASP MVC 5 app in virtual directory (without creating new iis application)
I use IIS 7.5
I already put
<modules runAllManagedModulesForAllRequests="true"/>
<directoryBrowse enabled="true" />
in web.config file.
But when i go to app url with IE browser it shows me just directory listing like in screenshot below
Is there a way to deploy MVC 5 in virtual directory and make it work like usual MVC application?
You need to convert the virtual directory to application. Right click on it in the IIS management console and choose Convert To Application.... Also make sure that the associated application is configured to use Integrated Pipeline Mode.
I solved this problem earlier in my production environment by checking the directory pointer in IIS. Apparently when I unzipped the deployed site from one server to the next, the zip utility made an extra level, so IIS was pointing to /MyProject when the files were in /MyProject/MyProject. I had a little better clue though, you have Document Browsing enabled based on that screen shot, make sure not to do that in production. I set the site to log custom errors and got a 403.14 response, from there found a blog on my mistake. You need to setup the environment to find the specific module that's failing, I think something to do with trace routes, idk. I'm a software developer that always gets forced into doing devOps; was googling my own problem and thought I'd throw you a line. Without a specific error message, all I can tell you is IIS is not connecting to .NET; something is not configured correctly. Turn off directory browsing, google how to get good error logs back, and let us know the status code so we can help you: 403.14, 401, 500, 404? Also give us the module that's failing. If it's the last one on the handler list, guess what, IIS isn't connecting to the app, which I suspect is your case.

How to solve the 500 Server error in asp.net mvc without enable the error show stuff

I am using asp.net mvc 4 for my project. my project is going well. I wonder about a thing.
I make a controller Test and ActionResult Index() this action doesn't need any viewdata or any kind of things.
Now When I test it in my local computer it's should work and it is. no problem.
Now amazing thing is it's doesn't work on server.
500 - Internal server error.
There is a problem with the resource you are looking for, and it cannot be displayed.
I am amazed that what happen to my code when everything work without any exception.
Now when I told other people about log they don't have anything. I don't want to install any nuget package on live site to test it. Do someone help me to solve this without adding any error checking module.
How I can check the issue on server.
IIS will log 500 errors in the Event Logs. So assuming you have access to the server, you can check there.
Well, I'm sorry but you have to be willing to do something... If you don't want to install packages like Elmah or enable remote iis debugging or etc... the only other thing that comes to my mind is for you to just start changing random stuff and hope it works. Also, most of these 500 internal server errors are caused by something in the web.config file. Make sure everything is set and good in there.
A very common reason for getting 500 Internal Server error is : Issue in Web.Config file.
Many times one can have some tags not closed properly OR missing Double quotes etc..
In general some syntax error is present most of the times in Web.Config. So make sure atleast you PASS this case.

Cannot debug unless browsing on localhost/siteName

I have a couple of MVC3 web applications in my project. I have added entries to my hosts file as follows:
127.0.0.1 local.mysite.com
127.0.0.1 admin.local.mysite.com
Both application's properties are set to use Local IIS Web server with the project URLs as follows:
http://localhost/mysite.web
http://localhost/mysite.web.admin
When I try to debug from Visual Studio, I can debug the "mysite.web" project from both http://localhost/mysite.web and http://local.mysite.com
For some reason, the "mysite.web.admin" project will only debug from http://localhost/mysite.web.admin
Any breakpoints I set will not be hit when I browse to http://admin.local.mysite.com
I dont recall doing anything different\special to allow "mysite.web" to be debuggable from other domains.
Any ideas?
Put a Debug.Break(); in you code and see what happens. You might have to create an app pool that runs as Bryan to use this approach.
Why do you need to use http://admin.local.mysite.com ?
This is not a MVC question, there is probably lots of info if you look/ask in Web Forms.
Can you debug from http:///mysite.web.admin ?
I wish I had a more detailed answer but all I can say is that after trying dozens of things found across the web, everything began working after a simple reboot.
My best guess is that the DNS resolution was cached somewhere. I flushed my DNS, restarted IIS, restarted VS2010, etc but none of them seemed to be the issue.
I dont know where it was cached but the reboot solved it.

MVC.NET 404 outside of Domain

I am trying to get a demo site for a client setup. This is the 1st application my company is doing in MVC.NET, so I get to experience all the new things to find out (and all the headaches it'll cause).
Anyway, the site works fine locally (localhost) and on the server inside our domain. External users not on the domain however, only get 404 errors. I've tried several different settings/ config options I've found on this site, but nothing is working. I don't know if it's a web.config issue or an IIS issue, or even simply a permissions issue (though it has all the same permissions as the other sites we run with Web Forms).
IIS: v7 in intergrated mode.
Windows Server Web
Well, because you received a 404, the server is being reached okay which is a good sign. (Dealing with firewall issues at a company is always a lot of fun.)
A common problem for something like this is the use of virtual directories to host the website. For example, if the address to your site is http://example.com/MySite/, in MVC that would translate to: /MySite/View/Index.aspx. HOWEVER...if you are using virtual folders, /MySite/ may instead point to another spot on the server (e.g. C:\WebSites\MySite). If you are indeed using virtual paths, make sure you have your files stored at the correct path.
There is a troubleshooting tutorial here: http://support.microsoft.com/kb/248033
thanks for the answers everyone. Turns out it was something with our DNS routing setup with the sub-domains. It was getting rerouted to a place that didn't exist. Our IT guy finally got around to fixing it (ugh!)

Asp.Net-MVC application dying

I have a strange issue with an Asp.NET MVC application.
Using Asp.NET MVC 3 Preview 1 on IIS 7.5 - Integrated
After building the application everything runs fine. Then after some random amount of time (or sometimes after updating a view or js file) the application dies.
Meaning, requesting the root page, I get the 403 error and requesting any other page I get a 404 error.
After a rebuild everything works fine again for a little while until it dies again.
I am seeing this on two different development machines. Also, I have another application which is very similar (MVC 3, IIS etc) on both dev machines and this one runs without problem. I have inspected the config files in detail and cannot see anything of notable difference.
Does anyone know what could cause an application to die or where to look for further information? (I can still access elmah.axd though no information is there).
There's not much to go on here, but the 403 and 404 are clues that at least ASP.NET routing is not working; 403 is coming back because the web server thinks you want to do a directory browse, 404 because your request doesn't have a valid corresponding resource.
Since you are using the new version of MVC, I would suspect the issue may lye there. When you get the error condition, can you browse to a regular .aspx page? Does it execute server side code correctly?
You have the site hosted in IIS 7.5, not just the built in Visual Studio web server, right? Is it possible to turn on monitoring/event logging to see if IIS is taking a hit?
I apologize for not having any actual answer, sounds like you have a tough issue to debug.
Good Luck!

Resources