-
Notifications
You must be signed in to change notification settings - Fork 310
IIS Hosting Issues #629
Comments
WebListener cannot be used with IIS/Express, you must use Kestrel: aspnet/IISIntegration#8 |
I did tried using Kestrel. I have got the following errors. In Log file:
When I run web.cmd in command line.
|
You want me talk to @halter73? |
No, he's making @halter73 aware of the issue |
Thanks for the quick response. There seems to be some issue with Https schema. I tried to set manually as suggested here Manually setting Https Schema Also, `
` |
You only need to configure the server certificate with Kestrel if you're accessing kestrel directly rather than via IIS. When you proxy through IIS it only uses SSL/TLS/HTTPS between the client and IIS, it uses HTTP between IIS and Kestrel. |
@Mady007 Are you still having the permission issue when running web.cmd? If so, can you provide the full output of the command including the address you are attempting to listen on? |
Yes, I do have the permission issue but however I could get it go away when I provided the port number as part of server urls argument in project.json. But that is not what I desire. "web": "Microsoft.AspNet.Server.WebListener --server.urls https://MyMainSite.com:1234/dir1/dir2/MySite" When I'm attempt to listen on something similar to https://MyMainSite.com/dir1/dir2/MySite, without port number by running web.cmd following is output of the command. which has the same permission exception. Note: I'm trying to host my application on IIS under default web site. where dir1/dir 2/ Mysite is virtual path. Please let me know if you need further information. Thanks for your response. |
So the error indicates you're running into a permissions issue trying to bind to port 443 but not 1234. Typically, if it's simply that another process is already listening on the same port, you would get an error like:
@Tratcher do you know why there might be a problem with permissions? On my Windows machine I'm able to bind to 443 even without an elevated prompt. |
I'd bet IIS is already running on 80 and 443. |
@Tratcher is correct. IIS is already running on 80 and 443. There are multiple asp.net 4 applications which are deployed under the default website and they are up and running. Does IIS have to be configured as reverse proxy? |
Kestrel cannot share ports with IIS, you have to give IIS the port and have it reverse proxy the request to Kestrel on a random port. |
Ok. It would be great help if you can point to some documentation ? |
@Mady007 There is the official doc at https://docs.asp.net/en/latest/publishing/iis.html and my notes for IIS that apply to |
@guardrex Thank you! I have gone through those both links earlier. I have requested the documentation of reverse proxy the request from IIS to Kestrel. Anyways, I'm on it. There is no luck so far but will update once I'm done. @Tratcher : You mentioned "..reverse proxy the request to Kestrel on a random port".So the application has to listen on the random port. How to make application listen on the random port? Hosting in IIS is enough ? or have to run web.cmd in some kind of windows service? I appreciate your response. |
In RC1 Hosting automatically listens on the port specified by IIS via environment variable. See https://github.com/aspnet/Hosting/blob/1.0.0-rc1/src/Microsoft.AspNet.Hosting/Internal/HostingEngine.cs#L262-L276 This will move in RC2. |
I have reverse proxy the request in IIS by adding rewrite rules to my application web.config. Just to add my application is 2 level deep from Default web site. '
'
I have tested above rewrite by running web.cmd and I can see the request coming to http://localhost:9898. Here is command section of project.json
Now I wanted to make it work without running web.cmd. When I tried to access the url I have this error Does the rewrite rule requires any changes? I feel I'm close but something is missing. I appreciate your response. |
web.config does not apply to selfhost, and there is no url-rewrite there. I recommend removing the url-rewrite. HttpPlatformHandler takes care of it's own redirection to a dynamic port. You also can't use WebListener with IIS/Express, you need to use Kestrel. |
Sorry, I'm not using WebListener its a typo. I'm using Kestrel and want to host application in IIS. I'm trying to achieve your suggestion in earlier response "Kestrel cannot share ports with IIS, you have to give IIS the port and have it reverse proxy the request to Kestrel on a random port." How do I give IIS the port when it already have one(443)? In startup.cs class I have configured to use IISPlatformHandler
|
You configure IIS as normal to use whatever public ports you like, usually 80 and 443. HttpPlatformHandler implements the reverse proxy functionality, you don't need additional url-rewrite. HttpPlatformHandler will run web.cmd and specify the port to use via environment variable. Do not configure any addresses for kestrel, Hosting will take care of it (in RC1). |
I did everything but no luck so far. Please guide me. Since my app is two levels deep from Default website do I have to add environment variable as below?
Also, where does web.config of my application reside? at parent level? |
@Mady007 That workaround only applies to RC2 packages. For RC1 use this one instead: aspnet/IISIntegration#14 (comment) |
I redid all the steps from my initial comment except using Kestrel instead of WebListner and everything is working like charm. The main issue i faced was with copying the build over to server via ftp. Some of the dlls and nuspec files from packages directory were not copied over. I used a different client which copied everything then it worked fine. I never had this issue with vs2013 MsDeploy which has ftp option. And for 2015, i know this option is missing, but I tried to setup as suggested here Publishing Directly with FTP in VS. I'm getting an exception Thank you @Tratcher and all the participants. |
Before I close I have one issue with copying files to server. If a user is using the application then I cannot copy the files to the virtual path on server. It says Files are being used by another program. |
@Mady007 coming soon... aspnet/IISIntegration#81 |
We are closing this issue because no further action is planned for this issue. If you still have any issues or questions, please log a new issue with any additional details that you have. |
I'm trying to host application on IIS, windows server 2008 R2, under default website. I tried to access the site through browser and it loads forever with below error in logs file.
Error: Unable to load application or execute command 'Microsoft.AspNet.Server.WebListener'. Available commands: web, ef. System.IO.FileNotFoundException: The system cannot find the file specified. (Exception from HRESULT: 0x80070002) at System.Reflection.RuntimeAssembly.nLoadFile(String path, Evidence evidence) at System.Reflection.Assembly.LoadFile(String path) at Microsoft.Dnx.Runtime.Loader.LoadContext.LoadFile(String assemblyPath) at Microsoft.Dnx.Runtime.Loader.PackageAssemblyLoader.Load(AssemblyName assemblyName, IAssemblyLoadContext loadContext) at Microsoft.Dnx.Host.LoaderContainer.Load(AssemblyName assemblyName) at Microsoft.Dnx.Runtime.Loader.AssemblyLoaderCache.GetOrAdd(AssemblyName name, Func
2 factory)at Microsoft.Dnx.Runtime.Loader.LoadContext.ResolveAssembly(Object sender, ResolveEventArgs args)
at System.AppDomain.OnAssemblyResolveEvent(RuntimeAssembly assembly, String assemblyFullName)`
_However when I run web.cmd in command line the application starts listening. As long as it is live I can access the url from browser the pages are served. _
I have used MSDeploy to publish the code to file system and I uploaded those files to server under the directory MySite , which is physical path of the application.
MySite
App pool Settings:
Control Panel HttpPlatformHandler
I have gone through the integration issues thread IIS Integration Issues. And added environment variable to web.config and added Configure1 method in startup.cs as suggested by Poul Kjeldager Sørensen
s093294
web.config
<configuration> <system.webServer> <handlers> <add name="httpplatformhandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" /> </handlers> <httpPlatform processPath="..\approot\web.cmd" arguments="web" stdoutLogEnabled="true" stdoutLogFile="..\logs\stdout.log" startupTimeLimit="3600"> <environmentVariables> <environmentVariable name="VIRTUAL_PATH" value="/MySite" /> </environmentVariables> </httpPlatform> </system.webServer> </configuration>
Startup.cs
`
Project.json
`
`
I have followed the diagnosing dependency issue from davidfowl
Apart from above issue I have following questions.
I really appreciate your help.
The text was updated successfully, but these errors were encountered: