Deploy asp.net mvc website to iis 8 - c#

After developping my Website using ASP.NET, C# and the MVC pattern, i'm now to the point of deploying my site to a 'real' server (not IIS express from visual studio anymore).
So, i tried to use Web deploy, configured everything and it seem to have been properly done because i now see all my files from the server side.
But sadly, when i try to access the website, i run into error 403 (from both the client and the server), the server gives me a little more information :
"Error 403.14 - Forbidden - The server isn't configured to show the
files of this directory"
If i try to use the url as i did with Visual Studio (like, url/Views/Home/) and it returns this :
Error 500.19
28: <system.webServer>
29: <handlers>
30: <remove name="BlockViewHandler"/>
Here's the web.config files concerned : (a bit)
<system.webServer>
<handlers>
<remove name="BlockViewHandler"/>
<add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" />
</handlers>
I don't see where's the problem, as this website was running fine from Visual Studio.
The deploy is done in release mode.
EDIT: I enabled directory browsing, and it returns the same error 500 when i get in the 'Views' folder

There can be many reason for this issue, I also faced this problem and it was due to connection string, I was using Integrated Security=true
1) To fix the issue I added Sql User in my connection string and it solved my issue
e.g. your connection string should look like
User ID=testuser;Password=testpassword;Initial Catalog=testdb;Data Source=testserver
2) Another reason could be that your MVC project has a different .Net framework from Application pool in which you hosted your site

I solved my own problem by removing "development" features from the server, reboot, add them again and it was fine.

Related

How to setup a .NET core HTTP Proxy in IIS [duplicate]

This question already has answers here:
HTTP Error 500.19 when publish .net core project into iis with 0x80070005
(11 answers)
Closed 2 years ago.
Need help to configure .NET Core HTTP proxy application on IIS on Windows 10.
I did build an proxy app to help me inject the SOAP headers before passing the request to the Final WS endpoint.
I had build this proxy because the client wont have a capability to send on headers on the request
I am mimicking the code that was shared by Andrea Chiarelli in the following link
Auth0 .NET Core Proxy
When I run the application locally on VS Code Everything works well
But soon I deployed to IIS server sing VS 2017. I ran into a problem
Web.Config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\EMCIProxy.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
</system.webServer>
</configuration>
I am getting a strange response that I cannot access the specific URL resource
HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.
Detailed Error Information:
Module
IIS Web Core
Notification
Unknown
Handler
Not yet determined
Error Code
0x8007000d
Config Error
Config File
\?\C:\inetpub\EMXI_Proxy\web.config
Requested URL
http://localhost:8085/
Physical Path
Logon Method
Not yet determined
Logon User
Not yet determined
Config Source:
-1:
0:
I am trying to access the URL http://XYZ123:8085/services/SearchClient which should be routed to
https://testxyz:7443/EMXI/services"
Just want to mention I exactly have one method public async Task Invoke(HttpContext context) similar to the one on the example provided in the above URL
Any points of advice/suggestions welcome. I am trying to leave it very generic as much as possible.
I just figured out that ASP Windows Hosting Module was not installed on my machine. Just want to point to another stack question, where I found the solution
enter link description here

.net core 2.0 app blocks plesk-webstat

I published an aps.net core 2.0 mvc app to a shared web hosting server that uses Plesk as control panel. The app works fine. However, I got the following error message when trying to access the web statistics:
This example.com page can’t be found
No webpage was found for the web address: https://example.com/plesk-stat/webstat/
HTTP ERROR 404
I contacted their support and got the answer "the .net core application settings aren't allowing the webstats to load. We recommend you consult with an experienced website developer to customize the web.config code accordingly for the website.", but they don't know how to configure the web.config file.
I really want to make the webstat to work. Any suggestion will be appreciated.
If URL Rewrite is blocking the access, try adding this string to the <conditions> section of the rule which is affecting webstat page:
<add input="{REQUEST_URI}" pattern="^/(plesk-stat/webstat)" negate="true" />
If that does nor help, configure failed request tracing to find which exact module is performing a redirect.
Along with changes in the web.config of the ASP.Net Core site itself to send the /plesk-stat/ url to IIS, a web.config must be added in the following directory:
C:\Inetpub\vhosts\{domain.tld}\.plesk\statistics\{domain.tld}\
(replace {domain.tld} with your domain), with the following contents:
<configuration>
<system.webServer>
<handlers>
<remove name="aspNetCore" />
</handlers>
</system.webServer>
</configuration>
This has to be done by the hosting provider on the server. Maybe you should contact the support of your hosting provider.

ASP.NET Core deployed on IIS returns 502 Error for long running requests

I have an ASP.NET Core 2 web application which is hosted on IIS 10 on Windows Server 2012 without any load balancing and special configurations. For some MVC actions which takes too long we get a 502 HTTP error.
After seeing this error I was shocked, because I didn't have any configuration for a proxy server, etc. And then I remembered that the ASP.NET Core runs on Kestrel. So I came to this conclusion that here IIS plays the role of the proxy server and forwards the requests to the Kestrel. So I think this is somehow related to a timeout configuration, as the other parts of the application works very well. I have searched for similar questions on SO but no luck finding a solution.
By default, ASP.NET Core request time out is 2 minutes, and you can change it via requestTimeout in setting file. See more here
requestTimeout Optional timespan attribute.
Specifies the duration for which the ASP.NET Core Module will wait for
a response from the process listening on %ASPNETCORE_PORT%.
The default value is "00:02:00".
The requestTimeout must be specified in whole minutes only, otherwise
it defaults to 2 minutes.
I am getting same error when data is huge and take more time to execute web page, I have changed timeout value for .netcore in web.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule"
resourceType="Unspecified"/>
</handlers>
<aspNetCore requestTimeout="00:20:00" processPath="%LAUNCHER_PATH%"
arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false"
stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false"/>
</system.webServer>
</configuration>
I have add requestTimeout="00:20:00" in my existing web.config file and it works.
for reference go to this url

IIS Server & ASP.Net Core - 500.19 with error code 0x8007000d on httpplatformhandler tag

I am getting the following error when I try to launch my ASP.Net Core App using IIS Server v7.5 ... I published the website (File System option in Visual Studio) to a specific directory successfully. It launches fine from approot/web.cmd file. But when I try to hook it up to IIS Server and point it to the wwwroot folder, I get the following error:
HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.
Detailed Error Information
Module IIS Web Core
Notification Unknown
Handler Not yet determined
Error Code 0x8007000d
Config Error
Config File \?\D:\WebDevelopment\UAT\creativeNamePROD\wwwroot\web.config
Requested URL http://10.2.177.226:59/
Physical Path
Logon Method Not yet determined
Logon User Not yet determined
Failed Request Tracing Log Directory
Below are two different web.config files I tried any neither one worked. When I try to get into Configuration Editor within IIS, I get an unclear error as well. Any help would be greatly appreciated!!!
<configuration>
<system.web>
<httpRuntime maxQueryStringLength="64768" maxUrlLength="65536" />
</system.web>
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxQueryString="64768" />
</requestFiltering>
</security>
<handlers>
<add name="httpplatformhandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
</handlers>
<httpPlatform processPath="..\approot\web.cmd" arguments="" stdoutLogEnabled="false" stdoutLogFile="..\logs\stdout.log" startupTimeLimit="3600"></httpPlatform>
</system.webServer>
</configuration>
Web.config #2 -gets the same error
<configuration>
<system.webServer>
<handlers>
<add name="httpplatformhandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
</handlers>
<httpPlatform processPath="..\approot\web.cmd" arguments="" stdoutLogEnabled="false" stdoutLogFile="..\logs\stdout.log" startupTimeLimit="3600"></httpPlatform>
</system.webServer>
</configuration>
I was getting this error. I fixed this error by installing the .NET Core Windows Server Hosting bundle (vs the Runtime Bundle), as described in instructions like this one.
Install the .NET Core Hosting Bundle
Install the .NET Core Hosting Bundle on the hosting system. The bundle installs the .NET Core Runtime, .NET Core Library, and the ASP.NET Core Module. The module creates the reverse proxy between IIS and the Kestrel server. If the system doesn't have an Internet connection, obtain and install the Microsoft Visual C++ 2015 Redistributable before installing the .NET Core Hosting Bundle.
As #Patrick says you can download the bundle installables from this link.
After installing that Module, my app served (i.e. no 500 error).
I see #Jørgen made this comment on OP already, so he gets credit.
EDIT Please confirm you install the Hosting bundle vs the Runtime Bundle per comment by #MDave
Did you install the .NET Core Windows Server Hosting bundle? This is needed for IIS to work as a reverse proxy for the .net core libraries. You'll find the link in this article: learn.microsoft.com/en-us/aspnet/core/publishing/iis I had the same problem before installing this on my dev machine. – Jørgen Tvedt Mar 28 at 6:31
The only solution worked for me was to install 2 more items from Microsoft dot net core library:
https://www.microsoft.com/net/download/thank-you/dotnet-runtime-2.0.6-windows-x64-asp.net-core-runtime-installer
and
https://www.microsoft.com/net/download/thank-you/dotnet-runtime-2.0.6-windows-server-hosting-installer
This worked for me, delete file: project.lock.json and run dotnet restore, restart visual studio.
I was able to solve this same problem when running in Visual Studio Community 2017 v. 15.7.1.
Had to install the latest dotnet-sdk-2.1.300-rc1-008673-win-x64.
https://www.microsoft.com/net/download/dotnet-sdk-2.1.300-rc1-windows-x64-installer
I had this problem with one .NET 6.0 site, but not another, so I knew the hosting pack was installed and functioning correctly.
The issue turned out to be that the broken site had some elements pertaining the URL Rewrite module, but the module wasn't installed.
Problem solved by either removing those elements, or installing the URL Rewrite module.

In Asp.Net 5 where does %DNX_PATH% in the wwwroot/web.config come from?

I'm trying to understand the boot process for and Asp.net 5 app running on IIS or IIS Express. My understanding so far is that when a request comes in to IIS, it runs the httpPlatform handler due to the following code specified in the wwwroot/web.config file:
<configuration>
<system.webServer>
<handlers>
<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified"/>
</handlers>
<httpPlatform processPath="%DNX_PATH%" arguments="%DNX_ARGS%" stdoutLogEnabled="false" startupTimeLimit="3600"/>
</system.webServer>
</configuration>
So when IIS runs the httpPlatformHandler, I believe it gets it's config information from the httpPlatform tag above. This is correct right? Where does "%DNX_PATH% come from? and Where does "%DNX_ARGS%" come from? How do these place holders get their values?
If I can understand this, then I can probably get a better idea of what the next step in the process is. Thanks!
%DNX_PATH% is set when you install ASP.NET 5.
When you download the installer from http://get.asp.net, it will automatically download the first piece of the puzzle which is dnvm.
dnvm will allow you to get the latest (and previous) .NET runtime.
This runtime will be used in web.cmd to create the variable %DNX_PATH% that will then be inserted in that configuration file.
It is important to know that you do need dnx installed on this machine to run it.

Categories

Resources