How to run an asp.net application in local IIS - c#

I am kind of new to asp.net.
I have created an application using Visual studio 2013 Web Express and MVC5. When I wanted to run the application, I was pressing the run button from VS and it managed to open it.
Now I switched the server from IIS Express to Local IIS. When I run the application in the browser, it gives me
Server Error in '/' Application. <br>
Access is denied.
Description: An error occurred while accessing the resources required to serve this request. The server may not be configured for access to the requested URL.
Error message 401.2.: Unauthorized: Logon failed due to server configuration. Verify that you have permission to view this directory or page based on the credentials you supplied and the authentication methods enabled on the Web server. Contact the Web server's administrator for additional assistance.
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18446
I guess because I don't have like Default.aspx file or something, I don't know what is the problem ??

This is a permissions issue. When you develop and run an application inside visual studio it has all the rights it needs. So you need to configure iis when wanting to demo/use the site directly from the webserver. After you have made the application inside IIS -> select the application and in the Actions pane you should see the link 'Edit Permissions'. Clicking that brings up the properties tab and under security add your account or an administrator account and elevate the rights until the site works.

I managed to get it working.
The problem was, I am using windows authentication to access the web application (VS asked me when the project first created). Now I didn't know I need to set it in the iis too.
All I did is enabling the Windows Authentication in iis > MySite > Authentication.

Related

The page you are requesting cannot be served because of the extension configuration. If the page is a script, add a handler

HTTP Error 404.3 - Not Found The page you are requesting cannot be served because of the extension configuration. If the page is a script, add a handler. If the file should be downloaded, add a MIME map.
I am new to IIS and ASP.net .
I developed an application in asp.net 4.0 using c#. ( on my laptop)
I Published the website in File System . ( on my laptop)
I installed 'IIS 8 Web Server' on 'windows Server 2012 R2' by using windows add feature option.
I copied the website published folder on Windows Server 2012 R2 from my laptop.
I created an Application pool on IIS.
I added a new website and created its virtual directory.
Added the home.aspx page in the default Documents.
and Now I am getting this error which I am unable to debug . Please help.
It depend on what extension are you requesting for. IIS return 404.3 when either there is no handler could handle the request or the extension is not included in mime type.
1.Please ensure asp.net and extension feature has been installed from turn windows features on or off.
2.If you get 404.3 when you request static file, please remember to register mimetype for it.
https://learn.microsoft.com/en-us/iis/configuration/system.webserver/staticcontent/mimemap

403 forbidden after publishing asp.net MVC IIS 8.5

I have been googling for hours and tried numerous solutions but nothing work. Any help is appreciated. I'm using IIS 8.5
I created a plain basic MVC application with no additional code. I published this plain default mvc template application to the server.
When I enter the address in the browser I got this error:
403 - Forbidden: Access is denied. You do not have permission to view this directory or page using the credentials that you supplied.
Error:
When I browse to it from the server via IIS I got this error:
403 - Forbidden: Access is denied. You do not have permission to view this directory or page using the credentials that you supplied.
I tried to
WebServer(ISS)->WebServer->Application Development add .NET
Extensibility 3.5 add .NET Extensibility 4.5 add ASP.NET 4.5 add
ISAPI Extensions add ISAPI Filters
register it via command line (aspnet_regiis.exe -i)
check network service permission
toggle app pool credential with a specific account
runAllManagedModulesForAllRequests="true"
... run out of ideas =(

Web Deploy to IIS fails. Why?

I am trying to deploy a .net core c# app to an IIS running on Windows Server 2016. I created a publish profile. I click on Validate Connection button and get the following error, that I need to install Web Deploy and that Web Management Service should be started:
I did install Web Deploy 3.6 and the Web Management Service is definitely running.
Here is my profile. The Site Name is AppPool\WebSiteName. User name is the same as I logged in on the server with.
What am I missing?
Figured out the problem. The Server entry needs to have the protocol. So http://winserver instead of just the name of the box.

Run MVC4 webapplication on local IIS webserver

UPDATED - pointed to the wrong directory at first. Thanks for the tip Wiktor. Still not succeeded in running the MVC4 application via
I am trying (for a while now.. :)) to set up a simulated multi tenant webapp on my development PC. I learned that this is not possible with visual studio's internal webserver, so I am trying to set up IIS.
I added the fake tenants in my hosts.
127.0.0.1 localhost
127.0.0.1 tenant1.mydomain.com
127.0.0.1 tenant2.mydomain.com
In IIS I made a new website test(port 8081), and just pointed it to C:\Azure\Websites\. In that directory I added a Hello World html file to see if this bit works.
I navigated to localhost:8081 => Hello world
I navigated to tenant1.mydomain.com:8081 => Hello world.
Cool, first proof of life.
Next step: getting this working with a MVC4 webapp created in VS2012.
I started a new MVC4 webapp and stored it in:
C:\Azure\Websites\MvcApplication1
I just use the default generated website for the test, so I pressed F5 and verified the site is opened in firefox. So the goal is to get this working from IIS.
Created a new website test2 (port 8082)
Set test2 app pool to .net4.0
Point the physical directory to C:\Azure\Websites\MvcApplication1\MvcApplication1\
Navigate to localhost:8082
HTTP Error 500.21 - Internal Server Error
Handler "ExtensionlessUrlHandler-Integrated-4.0" has a bad module "ManagedPipelineHandler" in its module list
Uninstalled ASP.NET and reinstalled it again. Same results.
when I change web.config from
preCondition="classicMode,runtimeVersionv4.0,bitness32"
to
preCondition="integratedMode,runtimeVersionv4.0,bitness32"
Then I get this error:
HTTP Error 404.2 - Not Found
The page you are requesting cannot be served because of the ISAPI and CGI Restriction list settings on the Web server.
Can I stress the fact that I am a n00b regarding IIS configuration... :)
Any ideas?
ISAPI and CGI Restictions in IIS:
Add isapi dll for .net 4 32bit
Add isapi dll for .net 4 64bit
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll
C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll
And it works. Finally!
Thanks Wiktor
First configure IIS according this site:
IIS 7.5 handler "extensionlessurlhandler-integrated-4.0" has a bad module "managedpipelinehandler" in its module list
For the above issue, you must go to Control Panel >> Installed Programs and Features >> Repair your .NET Framework by double clicking on it.
first configure IIS as
Manual configuration
Open your Control Panel and click Programs and Features » Turn Windows features on or off.
Turn on Internet Information Services.
Under Internet Information Services, turn on the following features:
Web Management Tools » IIS 6 Management Compatibility » IIS Metabase and IIS 6 configuration compatibility.
Web Management Tools » IIS Management Console, IIS Management Scripts and Tools, and Management Service.
Under World Wide Web Services, turn on the following:
All features under Application Development features, except Server-Side Includes.
Common HTTP Features » Default Document, Directory Browsing, HTTP errors, Http Redirection, Static Content.
Security » Basic Authentication, Request Filtering, Windows Authentication.
Under Microsoft .NET Framework 3.5.1 » Windows Communication Foundation HTTP Activation.
After you have created your website, open the Internet Information Services (IIS) Manger.
Expand your server node.
Expand Sites node and click your website.
In section IIS on the right, double-click Authentication.
Perform one of the following:
If you are using Forms authentication, make sure Anonymous Authentication and Forms Authentication are enabled and all other authentications are disabled.
If you are using Claims-based authentication, make sure only Anonymous Authentication is enabled and all other authentications are disabled.
Click your website again and in IIS section, double-click Handler Mappings.
Make sure you have enabled handler mappings for *.svc and *.xamlx with executable path set to one of the following:
For 64-bit OS: %windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll
For 32-bit OS: %windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll
Close the Internet Information Services (IIS) Manger.

How to enable Windows Authentication on ASP.NET Development Server?

We are trying to host a WCF service via the web. We set the web.config to have the service require windows authentication. The problem we are having is the following:
When we host our service in a regular IIS, the service runs fine and there is no issues with the "Windows Authentication" mode. However, when we try to run it from our developer boxes we get the following error: "Security settings for this service require Windows Authentication but it is not enabled for the IIS application that hosts this service."
Our developers boxes are not hosting the service through the regular IIS but rather through Visual Studio's ASP.NET Development Server. We tried going into the web project properties and said to enable NTLM authentication but that still did not fix it. Does anyone know how to fix it? Does VS ASP.NET Development Server even support Windows Authentication? Is the only option for hosting the service with Windows Authentication is to use IIS and forget about ASP.NET Development Server?
In order to configure IIS Express security settings:
look for the IIS express symbol in the taskbar (system tray).
Right click and select "All Applications".
Click on the name of the site you want to change (although I believe the change is site wide)
Click on the path in the config section below (it will open the applicationhost.config file)
Search for the authentication section and make your changes
Example changes can be found here:
http://toadcode.blogspot.ca/2011/08/security-config-in-iis-express.html
ASP.Net Development Server is very limited. It only serves requests originating from the same machine that it is running on, and it will not serve files that are outside of its application scope. It is based on the Cassini server. Cassini does not support WCF web services. Documentation for ASP.Net Development Server says that it does support NTLM. If you are just browsing to a page from the local machine it should work fine unless the page is referencing an unavailable resource.
check out http://msdn.microsoft.com/en-us/library/58wxa9w5.aspx for more info.
I would install and configure IIS on your local dev machine and use that in preference to using the inbuilt webserver. To use local IIS to debug select "User Local IIS web server" on the web tab of the project properties. Using IIS rather than the inbuilt webserver also means that you can configure your app in exactly the same way as it will be configured on the production server and this will reduce the no of potential surprises when you move to the production environment.
The solution to my authorization issue was to go into the F4 project properties and set the following:
Anonymous Authentication: Disabled
Windows Authentication: Enabled
Apparently these properties update the IIS applicationHost.config directly.
http://provenstyle.com/blog/2015/10/02/Visual-Studio-2015-Windows-Authentication-And-IIS-Express/

Categories

Resources