Setting up separate ASP.NET app with DotNetNuke - web-config

I've got DotNetNuke (v5.1.4 Community Edition) setup on a Windows Server 2008 64-bit system (using SQL Server 2008 64-bit for the backend database), and I want to reference a separate ASP.NET application from it. I plan to display the ASP.NET application via an IFrame module on the DNN site. I'd like the ASP.NET application to recognize the user that is currently logged into the DNN site. I'm trying to do this by creating a web application (in IIS) under the DNN web site on the web server. That is, the ASP.NET web application is a child of the DNN web site (we're using IIS7).
When I do this and then navigate to the ASP.NET site I get this error message:
"Could not load file or assembly
'DotNetNuke.HttpModules' or one of its
dependencies."
Based on this article. I added the < clear / > tag to the httpModules section of the ASP.NET applications web.config.
Now I'm getting this error message:
"Could not load file or assembly
'DotNetNuke' or one of its
dependencies"
Also, the debugging information mentions something about DotNetNuke.UI.WebControls.CaptchaHandler, but I don't think that's the source of the problem. That is, it's just a coincidence that the CaptchaHandler is the first item in the httpHandlers section.
I tried adding the < clear / > tag to the httpHandlers section, but get this error message:
"No http handler was found for request
type 'GET'"
Any ideas on what might be going on and how to fix it?

You can modify the root dnn web.config and add <location inheritInChildApplications="false"> around the <system.webServer> and <system.web> tags.
The end result will be something along these lines...
<location path="." inheritInChildApplications="false">
<system.webServer>
...
</system.webServer>
<system.web>
...
</system.web>
</location>

Well I think you may have missed a step from that post - what you need to do is in the application that is sitting 'below' dnn make sure that you remove the http modules in its web.config. It doesnt sound like you have done that.

Related

Something wrong with my web.config file while hosting web service

To give some context:
I'm trying to deploy a webservice I built, within visual studio you have the option to use 'Folder Deployment', I am using this option and that deployment allows me to make a build within a folder that has an executable which works like a charm when I'm using it on localhost but because my webservice needs to be used through a network, I need to deploy it to IIS which gives me some challenges.
I'm trying to host my RESTful API web service on the IIS server as explained in this article: https://www.c-sharpcorner.com/article/publishing-asp-net-web-api-rest-service-using-file-system-method/ but every time I add it to the server, and try surfing to the site I get the following error page: HTTP Error 500.19 - Internal Server Error --> 0x8007000d which apparantly tells me that something is wrong with my web.config file but I never touched that during my development..... perhaps you guys see something odd as here is my web.config file:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\Flame_webservice.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
</system.webServer>
</location>
</configuration>
<!--ProjectGuid: 21d59c04-6877-4549-9ff7-c37f07155f97-->
After searching for solutions I already found several articles that suggested installing things but it doesn't seem to do the trick for me, the following article I have tried:
Web Application Problems (web.config errors) HTTP 500.19 with IIS7.5 and ASP.NET v2
I don't think I'm using AJAX but maybe I am so I haven't tried that yet.
My webservice contains 3 controllers which are essentially websites but I don't see an explicit route to the websites in the web.config file, I'm not sure if that can cause issues?
I will continue searching but it's becoming a pretty rough ride at the moment due to my limited experience with hosting web services. Or am I perhaps using IIS while I shouldn't? I mean I've tried turning off my firewall and reaching the executable running on localhost through my IP address but it doesn't seem to work which led me to believe I needed a server to reach the running web service on my local machine.
I had the same exact issue and what helped was:
installing .net core windows hosting on the server.
Install-Package Microsoft.Extensions.Hosting -Version 3.1.10

How to create IIS-website from powershell in order to host .net core 2.0 app, error 0x8007000d

Expected Result:
IIS hosts my app correctly, and when I navigate to the url of my app (e.g: blabla/swagger) I see the swagger UI describing my app
Problem:
When I try to navigate to my app it says:
HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.
Information
I built an app in .net core 2.0 and I am able to make it run through visual studio, being hosted by Kestrel.
However I need to deploy this app to different servers and since Kestrel doesn't support host names, I need to make it being hosted in IIS . When I make it run through Kestrel I am able to access it correctly and by navigating to the url/swagger address, I am able to see the correct swagger page that describes the app.
My app is being published from visual studio. Which means in its published folder there are all the dlls that the app needs. It's being published as a framework dependent app, not a standalone one, but this shouldn't matter.
How to replicate the problem
Since I need this one day to be hosted in IIS inside a Docker container, I am trying to make it being hosted in IIS with powershell scripts. What I did to make it being hosted in IIS is:
New-Website -Name 'myTestApp' -force -Port 8080 -PhysicalPath
'C:\Users\myUser\Desktop\Docker\PublishOutput' -ApplicationPool 'MyAppPoolTest'
Where C:\Users\myUser\Desktop\Docker\PublishOutput is the path to the published folder where Visual Studio publishes the app. Thanks in advance!
This is the web.config generated by Visual studio when publishing:
<?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=".\Friss.CaseApi.Web.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
</system.webServer>
</configuration>
<!--ProjectGuid: 313d542d-7676-4440-ae1b-22c6071f4309-->
And the error page is:
Am I setting the web.config in the wrong way?
Check the documentation here
You need to publish your website and then point IIS website to the published folder
Application pool must be set to No Managed code
Application Pool identity user IIS AppPool\{AppPoolName} must have read permissions on the published website folder
Found the solution,
the system requires the dotnet core windows hosting bundle. The bundle installs the .NET Core Runtime, .NET Core Library, and the ASP.NET Core Module.
Documentation: https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/?view=aspnetcore-2.1&tabs=aspnetcore2x
Direct download to the bundle for .netcore 2.0.6 that solved my problem:https://download.microsoft.com/download/8/D/A/8DA04DA7-565B-4372-BBCE-D44C7809A467/DotNetCore.2.0.6-1-WindowsHosting.exe

validateRequest and requestValidationMode dont work with .net 2.0

I am hosting WCF Service in IIS 7. They are running under .net version 2.0. Everything is working fine. But lately, i am getting error list "Potentially Dangerous request ...". I searched on the internet and found out have i have to set my web.config like this.
<system.web>
<httpRuntime requestValidationMode="2.0" />
<pages validateRequest="false" />
</system.web>
I updated my web.config but then I am not able to browse to the services. It is giving me this error.
Parser Error Message: Unrecognized attribute 'requestValidationMode'. Note that attribute names are case-sensitive.
Please help me to resolve this error.
Thanks,
Vivek
The requestValidationMode attribute was introduced in .NET 4.0.
Under .NET 2.0 you should only have to add <pages validateRequest="false" /> to your Web.config to avoid Potentially Dangerous request errors.
You can also turn request validation off for an individual page using <%# Page ValidateRequest="false" %>.
If you find requestValidationMode="2.0" in your web.config, it is very likely that the developer has been targeting against framework 4.0 or higher and you should probably set the application pool to the corresponding version, rather than change the settings.

ASP.NET MVC3 routing with areas not working only on deployment server

I have an Asp.Net MVC3 web applications, which uses Areas.
When I run it from visual studio using IISEXPRESS everything is working just fine.
But when I deploy the application to my test server, the application won't render any views which are located in areas.
On my development machine the url that is generated looks like this:
http://localhost:58366/myapp/settings/convertemplates
(settings = the name of the area, converttemplates = name of controller)
on the test server, the url is different:
http://testserver/myapp/converttemplates?Area=settings
How is it possible the routing works as expected on my development machine, but fails on the test server ?
I found the problem... (but I do not understand the implications...)
the config contained the following line
<system.web>
<compilation debug="true" targetFramework="4.0" optimizeCompilations="true">
when I remove optimizeCompilations="true" routing again works like expected.

ASP.NET MVC on IIS falls through to the static file handler

I have a problem with an ASP.NET MVC site.
These are the details:
ASP.NET MVC 2
ASP.NET 4 integrated pipeline
IIS 7.5 on Windows Web Server 2008 R2
Whenever I make a request for the app I get the "HTTP Error 404.0 - Not Found"-error and the detailed error information shows it is the static file handler that reports the error:
Module: IIS Web Core
Notification: MapRequestHandler
Handler: StaticFile
Error Code: 0x80070002
meaning that the request never entered the MVC stack.
I should note that the IIS already serves a ASP.NET MVC 3 on the same app pool and a MVC 2 on a ASP.ENT 2 app pool. So it's the combo ASP.NET 2 on the ASP.NET 4 app pool that are giving me headaches.
Basically I want to upgrade the app from ASP.NET MVC 2 on a ASP.NET 2.0 app pool to a ASP.NET MVC 2 on a ASP.NET 4.0 app pool.
So any ideas?
I see you fixed your issue, but for anyone googling:
I had this issue and in my case I just needed to register ASP.NET 4 with IIS. I was deleting and re-adding webs to fix other issues and simply forgot to do that. The command that worked for me was:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319>aspnet_regiis -i
Your own .net version may be different, especially if you are in the future, so the above path may not be exactly right.
I had the same problem when I installed IIS after installing Visual Studio, etc.
I was able to fix the problem by changing my Web.config file, adding the runAllManagedModulesForAllRequests="true" to the <modules> tag:
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
...
</modules>
</system.webServer>
(More details/copied from here: http://www.west-wind.com/weblog/posts/2011/Mar/27/ASPNET-Routing-not-working-on-IIS-70)
Chris' answer got me to check whether the app pool was actually configured for .net 4. Sure enough, this server defaults to creating 32-bit .net 2 pools in classic mode.
Ensure that your app is using 4.0 and you'll probably want Integrated pipeline for all new development. 32/64 is mainly up to your dependencies. The default is leaving "allow 32 bit allocations" set to false.
In my case, a similar error was thrown because StaticFile Handler was disabled / not working properly. I eventually fixed it by removing the handler and re-adding it through the web.config. Also, in case of a 403.3 error, change the RequireAccess-property value from "Write" to "Read"
<configuration>
<system.webServer>
<handlers>
<remove name="StaticFile"
<add
name="StaticFile"
path="*" verb="*"
modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule"
resourceType="Either"
requireAccess="Read" />
</handlers>
</system.webServer>
</configuration>
So I found the error. There was a left over default document in the root, which isn't necessary for apps using the integrated pipeline. Also some changes to Global.ascx and route registration was neessary, but after that it worked.