Hosting ASP.NET 5 WebAPI in IIS using a virtual directory/application - iis-7.5

I am trying to host a new ASP.NET 5 WebAPI project in IIS, and I am using the ASP.NET 5 RC 1 runtime. The project that I am using is the standard generated template for a new ASP.NET 5 WebAPI project. (No code changes.)
I have successfully published the project using the command line, and I can get the application to work in a new web site using a specific port, such as localhost:12345. For example, accessing localhost:12345/api/values returns the values.json data from the project template.
However, when I try to use an IIS Application folder for the project, I am getting a 404 error. In other words, localhost:12345/WebApi1/api/values returns a 404 error. But I can see Kestrel running on a random port in the Event Viewer, and if I access the data on that port, I do get values.json back, so I know Kestrel is running.
Is there something special that needs to be done to get an ASP.NET 5 WebAPI project working in an IIS Application folder under a web site?
Side note: if I use --server.urls to set a port for Kestrel, it's running both on the requested port and the random port logged in the Event Viewer. (So it's actually available from Kestrel from 2 URLs, not the single one configured by --server.urls.)

Kiran Challa's link above indeed does fix the problem. Put this in your Configure method in Startup.cs
app.Map("/IISApplicationFolderName", (myAppPath) => this.ConfigureApp(myAppPath, env, loggerFactory));
where IISApplicationFolderName is the name of the IIS application folder that you want to host under. The rest of the configuration code moves to the new method ConfigureApp, since you're delegating your configuration to that method.
This also looks to be a temporary patch until ASP.NET 5 RC2 is released.

Related

edit web.config to pass parameters [duplicate]

I have an ISAPI DLL installed under a directory like:
c:\inetpub\wwwroot\emsserver\emsserver.dll
This is a Delphi RAD Server app.
In IIS Manager (Windows 10), under Root (computer name) -> Sites -> Default Web Site -> Emsserver, I have a handler set up to handle "*.dll" requests with that DLL. The end result is I can access the app like:
http://localhost/emsserver/emsserver.dll/some-action
That works fine. All good there, output as expected. But the URL isn't very end user friendly.
Question:
Using IIS Manager on Windows 10, how can I configure it so that I can access the application without the DLL portions of the URL? So, like "http://localhost/some-action"?
Seems like it should be a simple enough thing to do, but I'm not seeing how. I tried setting up a handler both in the root server entry in IIS manager, as well as for the 'Default web site', but neither did the trick. I haven't used IIS in 20 years (been almost exclusively Linux & Apache), so I'm a bit out of my usual neighborhood.
You can use url rewrite to achieve this. Download the module from here.
Here is the result of the rule.

HTTP Error 401.2 - Unauthorized with Error Code 0x80070005 with both IIS ans IIS Express

After attempting to configure IIS as a replacement for IIS Express, both stopped working and delivered the above error on deploying the .NET Core project in VS2019. According to IIS anonymous authentication is enabled, I also entered explicit user name and password as well as giving my user all rights to work with the project's directory. I restarted the IIS several times and re-created the pools and Pages, as well as repairing VS2019 in hope to get the IIS Express running again at least.
I have no idea what else I could do.
EDIT: I am using IIS10
Module
IIS Web Core
Notification
AuthenticateRequest
Handler
aspNetCore
Error Code
0x80070005
Requested URL
http://localhost:12345/
Physical Path
C:\inetpub\...
Logon Method
Noch unbestimmt
Logon User
Noch unbestimmt
You can try the following steps to solve your problem:
Right click on the project, go to properties.
Select the web, and then you will find a service setting
Change the project URL for other port, like http://localhost:44338/.
I was able to figure it out myself by now:
For some reason during setting up the IIS and IIS profile (accidentally or by some quirk of VS), the anynomous authentification setting was set to false. Which also affected the IIS Express to not work properly anymore. Simply enabled anonymous authentication resolved the issue for both.
Project Properties -> Debug -> IIS profile -> anonymous authentification: ✓

Kentico 12 DancingGoat MVC SiteName is empty or null

I have installed DancingGoat MVC and i can access the IIS urls just fine
http://localhost:8080/Kentico12_DancingGoatMvc
http://localhost:8080/Kentico12_Admin/Admin/cmsadministration.aspx
When I try to debug the MVC application to look into the inner workings of the sample site, in StartUp.auh.cs file i get SiteName is empty or null exception.
The exception is on following line
// Register Kentico Membership identity implementation
app.CreatePerOwinContext(() => UserManager.Initialize(app, new UserManager(new UserStore(SiteContext.CurrentSiteName))));
How can i rectify this?
The MVC project is likely setup in your Visual Studio to launch under a different port than :8080. Open the MVC project's properties, go to the web tab and note the port after http://localhost in the Project URL field. Then, back in Kentico, go to the Sites tool, and for the Dancing Goat site, add the URL and port to your site's domain aliases (or change the default one in the site setting). Relaunch everything and you should be good to go. Barring that, make sure you have a valid license for your site and localhost, etc.

use node.js express on iis with iisnode

I got a node.js express application and i need to make it run on my local IIS server so i can send valid http requests to it and work with the responses.
I am using win 10 and IIS 10.
I followed the different guides about working with iisnode in order to use node.js application on IIS.
https://github.com/tjanczuk/iisnode
I also managed to run the tests, so the iisnode is installed, valid and is working together with my IIS.
The "built-in" test is being executed under the default web site which comes with IIS, it creates a new application under it from which there is a working access to the different examples.
My problem is that i am still lacking some information about how to setup my own node.js app on IIS since this information seems to be lacking.
And later on how to overcome issues with invalid http requests.
HTTP status: 500
HTTP subStatus: 1001
HTTP reason: Internal Server Error
I would advice to follow the next guide,
https://harveywilliams.net/blog/installing-iisnode
combined with the official github page of iisnode,
it has all the details about making a simple express node.js app working from scratch with iisnode on IIS.
I would advice to test each part before moving on to the next and once done testing to start first from a minimalistic and simple app of your own and once everything is working build it up from there.
P.S. The reason for this error for me was bad naming when i used express.routing
step 1 :- Install Node js
step 2 :- Install IISNode :- from here
then root folder structure like below.
iisnode folder contains log file and index file.
step 3 :- create angular server side build so it will creates browser and server folder. add them in dist folder as shown in below.

IIS reverse proxy not working in Azure Web App

I want to use a reverse proxy to point one of my endpoints to a resource that's hosted elsewhere. My primary server (where everything else is hosted) is in an Azure Web App and is otherwise working perfectly.
I've been using this seemingly failproof article along with the other links mentioned at the bottom of it: https://blogs.msdn.microsoft.com/zhiliang_xus_blog/2016/01/19/build-a-google-reverse-proxy-site-on-azure-web-app-in-less-than-3-minutes/
As a baseline, I used a Web App with no additional code and confirmed that the reverse proxy works. This was done by manually creating/editing the web.config file and applicationHost.xdt file then restarting the server.
I've tried 3 separate approaches (all on clean, new web apps) all of which are failing for me:
Push my code, confirm it works, then follow the reverse proxy steps manually
Follow the steps manually, confirm reverse proxy works, then push my code
Put the reverse proxy files into my codebase and push everything at the same time
None of these 3 approaches are working. Is this a bug in Azure? How can I try to figure this out?
Post XML Transformation (XDT), have you restarted the site?
I would suggest you to take a look at this blog from Ruslan:
http://ruslany.net/2014/05/using-azure-web-site-as-a-reverse-proxy/
It talks about using a Site extension. It implements the reverse proxy and it does the XDT transformation for you.
If the above is setup correctly, then there is something wrong with the URL Rewrite rules. I would recommend you to enable Failed Request Tracing and debug this further.
The link/way you posted used URL Rewrite to implement a reverse proxy. I tested it and it worked fine with my empty web application. After published a web application to the Azure Web App(For example, an ASP.NET MVC web application), the URL Rewrite stopped working. The reason is that all the requests to your web application are routed by ASP.NET route module.
To enable URL Rewrite for some URLs, we need to disable ASP.NET route for these URLs. For example, if you want to rewrite all the requests with "product/xxx" format to another site. You could add following code to RouteConfig.cs file.
routes.Ignore("product/{action}");
The problem in this specific case was the location of my web.config file.
It needs to be in the root directory of the application which, in my case, was not site\wwwroot. My code was being generated and copied into site\wwwroot\dist. Putting the config file in that directory fixed the problem.
Additionally, there are logs that can be enabled to get some insight as to what's going on: https://learn.microsoft.com/en-us/azure/app-service-web/web-sites-enable-diagnostic-log

Resources