MVC Shows Directory Listing Not Loading Application - c#

I have a project that for some reason isn't loading the project, but just is showing me the directory listings. I have even tried running it in local IIS to see if it makes a difference and it doesn't
Things I have tried
modules runAllManagedModulesForAllRequests="true"
remove and reinstall IIS from manage windows applications in control panel
If I create a template MVC project in visual studio and run it , it runs fine so that makes me think its not my configruation. Other uses with the same project and web config are having no problem getting the site to load.
Also if I try and goto /Home/Index I get a 404 error. Not sure if that helps in any way
Any other ideas I may be missing here
IIS 10 on Windows 10

Check that IIS is installed and features you require are enabled
Register Asp.Net in Windows 10 for the Framework version you use.
dism /online /enable-feature /all /featurename:IIS-ASPNET45
Remove read-only tick and grant IIS with permissions on the folder your application is deployed.

You need to go over your IIS configurations again, do re-check whether you have the “Default Document” set for your website in IIS Manager.
Also, if you’re running directly via Visual Studio, check whether you have selected the relevant “Project” as the “Startup Project” for the Solution (visit https://msdn.microsoft.com/en-us/library/a1awth7y.aspx).
If the above fail, do recheck the IIS Permission for the particular project (visit https://support.microsoft.com/en-us/help/313075/how-to-configure-web-server-permissions-for-web-content-in-iis)
Lastly as mentioned above, do un-check the "Read Only" Flag if its there.
Do share your feedback and let me know if your problem still persists.

Related

How to deploy an ASP.NET application to localhost using IIS?

I'm trying to deploy an ASP.NET application to localhost using IIS, I've been reading a LOT of tutorials and following them step by step but I just can't seem to make it work...
I created an Application Pool(TestPool) with .NET version 4.0 and gave it every permission to the folder where the application is at.
I then added an application to the Default Web Site and tried to run it at
http://localhost/TestApplication/
But I keep getting:
Any idea what is wrong and how can I solve this?
Versions:
IIS version: 6.2
OS: Windows 8.1
VS 2013 Ultimate: 12.0
VS .NET: 4.6
PS: It's my first attempt at deploying an ASP.NET application so if you need any further information just leave a comment.
EDIT:
It is now running at least thanks to Julian and Marge, but when I run it using VS it has the default view, why isn't it showing when I run it through IIS? When running through IIS it just lists the files:
This error is because your website, in the IIS Server, does not have the Directory Browsing enabled and the default document (default page of the site ex: Default.aspx) configured.
Go to IIS Server IIS > Default Documents and check if the default page of your site is listed, if no, add the page.
Check the related link:
https://support.microsoft.com/en-us/kb/942062
Generally speaking, you do not need to access IIS manager at all to run your webpage on localhost. All what you need to do is right click on the project and then choose properties. In the Web tab you will find Servers section. Make sure the Project Url is something like http://localhost/myproj or simply http://localhost/ then hit Create Virtual Directory. Your webpage should be up by then, and you can access it either in debug mode, or simply by navigating your browser to the Project Url you have chosen.
When you add web application in IIS ex.
That your hostname should be to add in host file which is C:\Windows\System32\drivers\etc"\hosts
ex.
127.0.0.1 test.pln

WebApplication works fine on IIS Express but it doesn't on Local IIS

I have a problem with my web application. I develop using VS 2013 (run as Administrator) and Windows 8.
When I debug using IIS Express - everything works fine, without any errors (I run VS as Administrator). When I change project properties to use Local IIS (it's installed) - I cannot use external library which is placed in GAC (Microsoft.FlightSimulator.SimConnect). Also I run VS as Administrator.
Thrown error: "HRESULT E_FAIL has been returned from a call to a COM component" - this says nothing to me. This is thrown during creating new SimConnect object:
var simconnect = new SimConnect(...)
OFC, to use SimConnect, firstly Microsoft Flight Simulator should be launched (and it's started). This was proposed reason of the problem which I found in the Internet - second one was granting permissions (described below).
Details:
I have two projects in solution: library project (which is used to connect to the FSX) and web project (MVC - to present the results).
1) I tried to move whole library project content to the MVC project - nothing.
2) I used IIS manager to publish my website (with the seperate AppPool) - result the same as for Local IIS.
3) I granted permissions to the folder (where projects are placed) for my own AppPool and also for IUSR, IIS_IUSR and DefaultAppPool - full access. And nothing.
4) I ran FSX as Administrator - also nothing :/
I found the workaround: I moved the library project to the another project - console application where I used HttpSelfHostConfiguration to host that. And later, I call this api from the main project (MVC). For this solution everything works fine (I tested for Local IIS [debugging] and also for IIS Manager). I have to only run the Host Api project as Administrator.
I'm very curious what is the reason of the exception. And additionally: how to resolve that :)
It seems like the problem with the permissions - but I granted to the every used AppPool.
Can be the reason lack of permissions for dll in GAC? I don't think so, but I have no idea what to do. If yes, how to grant permissions for dll in GAC (or how to copy that)?
#Krzyrok, Had the same issue recently on my one of my projects where I used external libraries. After following endless crumbs I got it resolved. Change your application pool identity from "ApplicationPoolIdentity" to "LocalSystem". I also changed the sites Anonymous Authentication to "Application pool identity" from the specified IUSR but tested it and it can be left on IUSR. I also granted permissions to the folder for IUSR and IIS_IUSR.
If someone comes across this problem, it is possible that the problem is that you have not configured SSL for your localhost site. The site might be trying to communicate via https port 443 and it cannot find the site there. The site may be hosted only on the unsecure http port. To solve this problem,
Go to IIS Manager
Right Click on the Website
Click on Bindings on the right
Click on Add
Select https
Select the IIS Express certificate
Click OK
I was using the physical path of the \bin folder as the basic settings physical path of the web site in IIS. I forgot I had to publish the web service and use the publish path as the basic settings physical path of the IIS website.

Handler "ExtensionlessUrlHandler-Integrated-4.0" has a bad module "ManagedPipelineHandler" in its module list

To be honest, I've tried to turn a dirty trick on IIS and just when I thought that I was going to get away with it, I realized my workaround doesn't work. Here's what I've tried to do:
1) I have ASP.NET application which has Preloader class that inherits IProcessHostPreloadClient and does all the heavy initialization in Preload method implementation (application is complex and it's a part of an enormous system, so it requires approximately 2 minutes to establish connections to all necessary services and pre-instantiate some Unity registrations).
2) I have a lot of work that needs to be done on application shutdown (unsubscribing, disconnecting, disposing,...), and I guess the best place to do it is in *Application_End* method located in Global.asax.
3) Everything works just fine when I have user activity (first request after the Application Pool that contains aforementioned web application is started will cause *Application_Start* to be called and afterwards *Application_End* is called on Application Pool stop or recycle), but problems occur when there is no user activity and application tries to restart itself after being active for 48 hours (configured requirement). Since there was no requests, application officially didn't get started. Ergo, it can't be gracefully stopped since *Application_End* won't be called.
4) Now comes the messy part... I've tried to make a GET request from code at the end of the Preload method, and it worked. But this solution seemed bad to me, even though it worked. So, I've tried a lot of things, and the last thing I tried was this:
SimpleWorkerRequest swr = new SimpleWorkerRequest(string.Empty, string.Empty, tw);
HttpRuntime.ProcessRequest(swr);
... and that has done it's purpose. *Application_Start* was called, (I've checked response, it was containing login page that was supposed to be displayed in initial request) and on Application Pool shutdown application ended gracefully by doing necessary work in *Application_End*.
BUT
After the application was started (preloaded and initiated) in this manner, this is what happened when I wanted to reach application via Web browser:
HTTP Error 500.21 - Internal Server Error
Handler "ExtensionlessUrlHandler-Integrated-4.0" has a bad module "ManagedPipelineHandler" in its module list
I am unable to figure this out. Can anybody tell me why this happens and how to fix it?
If I don't figure this out, I will go back to first solution (sending GET request from code) but this problem will bug me since I don't even have an idea what's wrong.
Try to re-register ASP.NET with aspnet_regiis -i. It worked for me.
A likely path for .NET 4 (from elevated command prompt):
c:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -i
http://forums.iis.net/p/1190643/2026401.aspx
If you're running into this error with Windows 8/Windows Server 2012 and .Net 4.5 follow these instructions here:
http://www.britishdeveloper.co.uk/2013/01/handler-extensionlessurlhandler.html
Go to "turn Windows features on or off"
Then Internet Information Services
Then World Wide Web Services
Then Application Development Features
And then enable ASP.NET 4.5
This worked for me (although the wizard and wording is a little different in Windows Server 2012, but you'll figure it out). With this being said, why this is necessary after installing everything through the Web Platform Installer including all of the dependencies is completely beyond me...
Despite following most of the advice on this page, I was still getting problems on Windows Server 2012. Installing .NET Extensibility 4.5 solved it for me:
Add Roles and Features > Server Roles > Web Server (IIS) > Web Server > Application Development > .NET Extensibility 4.5
For Windows 10 / Windows Server 2016 use the following command:
dism /online /enable-feature /featurename:IIS-ASPNET45 /all
The suggested answers with aspnet_regiis doesn't work on Windows 10 (Creators Update and later) or Windows Server 2016:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -i
Microsoft (R) ASP.NET RegIIS version 4.0.30319.0
Administration utility to install and uninstall ASP.NET on the local machine.
Copyright (C) Microsoft Corporation. All rights reserved.
Start installing ASP.NET (4.0.30319.0).
This option is not supported on this version of the operating system. Administrators should instead install/uninstall ASP.NET 4.5 with IIS8 using the "Turn Windows Features On/Off" dialog, the Server Manager management tool, or the dism.exe command line tool. For more details please see http://go.microsoft.com/fwlink/?LinkID=216771.
Finished installing ASP.NET (4.0.30319.0).
Interestingly, the "Turn Windows Features On/Off" dialog didn't allow me to untick .NET nor ASP.NET 4.6, and only the above DISM command worked. Not sure whether the featurename is correct, but it worked for me.
Run one of these commands :
For 32 Bit Windows OS:
c:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -i
For 64 Bit Windows OS:
c:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -I
This https://stackoverflow.com/a/13266763/1277458 works perfectly. But if you have 64-bit operation system use Framework64 instead of Framework in path:
c:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -i
The problem
You are using SimpleWorkerRequest in a scenario that it wasn't designed for. You are using it inside of IIS. If you look at the prior MSDN link (emphasis is mine):
Provides a simple implementation of the HttpWorkerRequest abstract class that can be used to host ASP.NET applications outside an Internet Information Services (IIS) application. You can employ SimpleWorkerRequest directly or extend it.
Also, if you look at the MSDN documentation for the System.Web.Hosting namespace (SimpleWorkerRequest is in this namespace), you will also see something similar to the above (again, emphasis is mine):
The System.Web.Hosting namespace provides the functionality for hosting ASP.NET applications from managed applications outside Microsoft Internet Information Services (IIS).
The solution
I would recommend removing the call to SimpleWorkerRequest. Instead, you can use a Microsoft solution to make sure your web site automatically starts up after it recycles. What you need is the Microsoft Application Initialization Module for IIS 7.5. It is not complicated to configure, but you need to understand the exact options. This is why I would also recommend the Application Initialization UI for IIS 7.5. The UI is written by an MSDN blogger.
So what exactly does the Microsoft solution do? It does what you are trying to do - IIS sends a "get" request to your website after the application pool is started.
In my case (Windows 10 + IIS 10) i had to open "Turn Windows Features On or Off" and then go to Internet Information Services > World Wide Web Services > Application Development Features > and check ASP.NET 4.6
I solved this problem, adding in "Turn Windows features on or off"
The option ASP.NET 4.7
Making this its own post because this had me going for hours.
I saw maybe a dozen of similar posts here and elsewhere about this problema and the aspnet_regiis fix. They weren't working for me, and aspnet_regiis was acting odd, just listing options etc.
As user ryan-anderson above indicated, you cannot enter .exe
For those less comfy with things outside IIS on the server, here's what you do in simple steps.
Find aspnet_regiis in a folder similar to this path. c:\Windows\Microsoft.NET\Framework\v4.0.30319\
Right-click command prompt in the start menu or wherever and tell it to run as administrator. Using the windows "Run" feature just won't work, or didn't for me.
Go back to the aspnet_regiis executable. Click-drag it right into the command prompt or copy-paste the address into the command prompt.
Remove, if it's there, the .exe at the end. This is key. Add the -i (space minus eye) at the end. Enter.
If you did this correctly, you will see that it starts to install asp.net, and then tells you it succeeded.
Make sure that you have set your application-site version from v2.0 to v4.0 in IIS Manager:
Application Pools > Your Application > Advanced Settings > .NET Framework Version
After that, install your ASP.NET.
For 32-Bit OS (Windows):
C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -i
For 64-Bit OS (Windows):
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -i
Restart your application-site in IIS Manager and enjoy.
I know this is an oldie, but thought I might add some value. For those of us running Server Core outside of a domain (domain members can just run Server Manager remotely to add/remove features/roles), you have to resort to command lines.
Powershell users can type "Install-WindowsFeature Web-Asp-Net45"
That should be equivalent to using server manager.
I was challenged by the same error message, with .net 4.7 installed.
The solution was to follow one earlier mentioned post to go with the "Turn Windows feature on or off", where the ".NET Framework 4.7 Advanced Services" --> "ASP.NET 4.7" already was checked.
Further down the list, there is the "Internet Information Services" and subnote "Application Development Features" --> "ASP.NET 4.7", that also needs to be checked.
When enabling this, allot of other features are enabled... I simply pressed the Ok button, and the issue was resolved.
Screendump of the windows features dialog
Installing .NET 4.7 worked for me. I only had 3.5 installed prior.
I'm working on Windows Server 2012. .NET Extensibility 4.5 feature is on. WebDAVModule removed.
I was still getting 500.21 error on ASP.NET route '/docs'.
Changing 'skipManagedModules' to false fixed the problem.
<applicationInitialization doAppInitAfterRestart="true" skipManagedModules="false">
<add initializationPage="/docs" />
</applicationInitialization>
Thanks to https://groups.google.com/forum/#!topic/bonobo-git-server/GbdMXdDO4tI
I had this problem and found that removing the following folder helped, even with the non-Express edition.Express:
C:\Users\<user>\Documents\IISExpress
This error started happening to me out of nowhere last week, affecting the existing web sites on my machine. I had no luck with it trying any of the suggestions here. Eventually I removed WebDAV from IIS completely (Windows Features -> Internet Information Services -> World Wide Web Services -> Common HTTP Features -> WebDAV Publishing). I did an IIS reset after this for good measure, and my error was finally resolved.
I can only guess that a Windows update started the issue, but I can't be sure.
You could fix it by change the "ExtensionlessUrlHandler-Integrated-4.0" type in iis to System.Web.DefaultHttpHandler
For me, removing WebDAV from my server caused the application to return a 503 Service Unavailable Error message when using PUT or DELETE, so I re-installed it back again. I also tried completely removing .NET Framework 4.5 and reinstalling it and also tried re-registering as suggested but to no avail.
I was able to fix this by disabling WebDAV for the individual application pool, this stopped the 'bad module' error when using PUT or DELETE.
Disable WebDAV for Individual App Pool:
Click the affected application pool
Find WebDAV Authoring Tools in the list
Click to open it
Click Disable WebDAV in the top right.
Ta daaaa!
I still left the remove items in my web.config file.
<system.webServer>
<modules>
<remove name="WebDAVModule"/>
</modules>
<handlers>
<remove name="WebDAV" />
</handlers>
<system.webServer>
This link is where I found the instructions but it's not very clear.
This maybe not a usefull solution for OP but it concerns the same "error" message.
We are hosting PHP pages on IIS8.5 with .NET 4.5 installed correctly.
We make use of the preload functionality to make sure our application is always responsive across the board.
After a while we started getting this error at random.
In the web.config : I put skipManagedModules to true, -> don't do this!
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<applicationInitialization skipManagedModules="false" doAppInitAfterRestart="true">
<add initializationPage="/" />
</applicationInitialization>
...
Although website is php, the routing to the paging is managed by the modules!!!
I also ran into that problem. My MVC4 App is running on a Windows Server 2012 R2 with IIS 8.5. None of these posted solutions worked for me...installing the missing frameworks through IIS Features could have solved it but the installation always failed.
I had to use the Web Platform Installer and installed the following packages:
I was facing this issue in a web application hosted on a shared hosting server. So obviously did not have direct access to IIS, so could not apply many solution proposed here.
On the hosting provider's control panel I enabled error logging for IIS and ASP.Net. And then got to know that error actually lied in a missing cshtml.

How can I deploy an asp.net application using Visual Studio 2008

I am trying to publish a website using IIS, I made a virtual directory and in this directory I've added all the webpages and configured the virtual directory but still I am not able to run my web application.
Here is the step by step method to deploy an asp.net application
http://www.15seconds.com/issue/030806.htm
Please post any error message
Make sure that your are running the right asp.net Version...
check if in the asp.net tab if it's v 1 change it to v2
Could you please let me know the error message.( Check with minimum settings like startUp page , version, try publishing with Wizards etc)
In Visual studio, click on project, Properties, Web.
Under Servers, select Use local IIS Web server, then on Create virtual Directory.
Now, when you debug, the page should open in IIS, and Visual studio has taken care of most of the grudge work of setting up the IIS, all you will probably have to change is the security settings under IIS. Hope this helps.
If it is IIS7 check that your application has enough permissions to run:
IIS Actions Pane:
Basic Settings
Connect as (be sure to log in with Admin account first to test, then create you own specific user. Least Privilege Principle)
Test Settings (Authorization and Authentication is Green!)
Test your webisite
The question doesn't say what exactly the error is but you mentioned that you just created the virtual directory. Did you make it an web application? For IIS 6 follow this
link - Create and Configure Local ASP.NET Web Sites. In IIS7 just right click on it and convert it to application.
If its already a website, did you choose the correct framework? normally when you create a website it ill be assigned the default app-pool. If you have installed multiple dotnet then you might check which framework is in default app-pool. Then change the default app-pool to the correct version that is required by your website, or create a new app-pool.
There can be multiple reasons so if you could provide the error message then it would be easier to resolve the problem.
Thanks.

Visual Studio 2010 is not allowing me to debug my code

So, this interesting issue has been plaguing me for the past couple of hours. Visual Studio 2010 Ultimate no longer attaches the debugger and lets me debug my code.
If I use the built in development server, then everything works fine. If I switch to Use Local IIS Web Server (http://localhost/), then all it does it attach to w3wp.exe, but no DLLs or PDBs are loaded for anything. I can go to Debug > Windows > Modules, and literally nothing is loaded in this window. Conversely, when using the built in development server, the Modules window displays all the DLLs and shows that the symbols for my DLLs have been loaded. Something is obviously amiss. The VS installation is completely bone stock.
In IIS, my website is configured with ASP.NET 2.0 (because no 3.5 exists to select from the drop down), along with read / log visits / index this resource options checked on the "Home Directory" tab.
Some of my failed ideas:
1) If I attach to process on the iexplore.exe instance where the website is displayed, it loads Internet Explorer's DLLs, but not mine.
2) I've restarted the computer multiple times
3) I've invoked devenv.exe /resetuserdata once
4) I've confirmed that every project is indeed set to debug and not release.
5) Deleted all \bin contents and rebuilt the solution.
6) Deleted entire solution and repulled from Source Control.
Can someone tell me what is wrong with this thing? I'm going to have an aneurism from the headache this is causing me.
You need to attach it to the IIS worker process, which OS are you using? Make sure you attach with the Managed + Native flags, in the Attach to Process. What happens if you just run (F5) your web application inside Visual Studio (that automatically attaches a debugger)? Do you get any errors?
Well there are quite a few good answers here, but I have found that the root cause of the issue for me was application pool authentication configuration. Let me lay out the scenario that I experienced and the solution and perhaps it will help someone save time....and hair.
Scenario:
I want to debug an ASP.NET web application in Visual Studio 2010 but cannot use the built-in Visual Studio web server. The reason that I could not use the built-in web server is that my application referenced assemblies built specifically for a 64-bit architecture and the VS web server would not support these. So, I had to use the option "Use Custom Web Server" in the website properties to point the debugger at a published instance of my site on a remote IIS web server.
Issue:
Even with the web.config debug options set correctly to publish debug symbols in the assembly output (i.e. compilation debug="true"), the debugger would not attach to the remote IIS process and I did not hit any breakpoints
Environment:
The Visual Studio 2010 debugger was already installed on the remote IIS web server and was running as a Windows service under the LocalSystem account.
Solution:
Enable "Anonymous Authentication" in addition to "Windows Authentication" on the web site hosted on the IIS web server.
As soon as I enabled anonymous authentication, the correct symbols were loaded by the VS remote debugger and I was able to hit the breakpoints.
Hope this helps you guys out.
Have you tried deleting the browser cache? Sometimes the browser hangs on to old code which is incompatible with the current build and thereby prevents debugging.
Does it run the app - without the debugger attached? It smells like you are attaching the debugger to a wrong process
I've had an issue before where under the build configuration screen some projects are unticked for a particular solution configuration, causing them to not build and therefore not be debuggable. Can you confirm whether or not code changes you make are actually being built and executed?
Also, what version of Windows and IIS are you running? Is it possible that your process is running under an AppPool with an account that's different to the account you're logged in with and perhaps it's a permissions problem? If it's Vista/Win7, is UAC turned on and are you running VS as administrator? I'll also second the suggestion to try a fresh project and see what that does. Are you in the debugger users local group on the machine?

Categories

Resources