Will new web.config work without change on Azure - c#

I am reading this blog and wondering will this new web.config file work on azure as it is. Thanks.
https://blogs.msdn.microsoft.com/webdev/2016/05/16/announcing-asp-net-core-rc2/
<configuration>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified"/>
</handlers>
<aspNetCore processPath="%LAUNCHER_PATH%"
arguments="%LAUNCHER_ARGS%"
stdoutLogEnabled="false"
stdoutLogFile=".\logs\stdout"
forwardWindowsAuthToken="false"/>
</system.webServer>
</configuration>

Yes the new aspnet core configuration file will pickup the app settings as environment variables and work very similar to how they do now

Related

ASP.NET Core 3.1 application having InProcess hosting model is getting timeout after 1 minute

What should be done if we want to increase the request timeout for asp.net core 3.1 application with InProcess hosting model? Our application is getting timed out in such scenarios.
We tried setting requestTimeout property in web.config but as written in link (https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/aspnet-core-module?view=aspnetcore-3.1#in-process-hosting-model), it is getting ignored.
So we are not sure what can be done for the same, please help.
Thanks
Hardik
Add web.config file to your project and write like these codes on it.
<?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>
You can read more on here

Visual Studio 2019 IIS profile creates web.config file that breaks Azure App Service

When creating a new Debug profile with Microsoft Visual Studio Community 2019 Version 16.6.3 on a ASP.NET Core Web 3.1 project a web.config file is created.
The file looks like this:
<?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="C:\Users\<USER>\Source\Project\Project.Web\bin\Debug\netcoreapp3.1\Project.Web.exe" arguments="" stdoutLogEnabled="false" hostingModel="InProcess">
<environmentVariables>
<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" />
</environmentVariables>
</aspNetCore>
</system.webServer>
</location>
</configuration>
Errors present when accessing the site with web.config:
AggregateException: One or more errors occurred. (One or more errors
occurred. (The NPM script 'start' exited without indicating that the
create-react-app server was listening for requests. The error output
was: )) System.Threading.Tasks.Task.ThrowIfExceptional(bool
includeTaskCanceledExceptions)
InvalidOperationException: The NPM script 'start' exited without
indicating that the create-react-app server was listening for
requests. The error output was:
Microsoft.AspNetCore.SpaServices.ReactDevelopmentServer.ReactDevelopmentServerMiddleware.StartCreateReactAppServerAsync(string
sourcePath, string npmScriptName, ILogger logger)
I first thought that the exact aspNetCore processPath was the culprit but given the error it more looked like code from Startup.cs.
if (env.IsDevelopment())
{
spa.UseReactDevelopmentServer(npmScript: "start");
}
Looking at the actual file deployed it confirmed my suspicions, the path was relative here.
I needed to set ASPNETCORE_ENVIRONMENT as Production. Solved this by creating a new web.release.config file since I needed to test the application on an actual IIS with ASPNETCORE_ENVIRONMENT as Development. With this transformation everything worked:
<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<!-- To customize the asp.net core module uncomment and edit the following section.
For more info see https://go.microsoft.com/fwlink/?linkid=838655 -->
<!--
<system.webServer>
<handlers>
<remove name="aspNetCore"/>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified"/>
</handlers>
<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
</system.webServer>
-->
<location>
<system.webServer>
<aspNetCore>
<environmentVariables>
<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Production" xdt:Locator="Match(name)" xdt:Transform="SetAttributes" />
</environmentVariables>
</aspNetCore>
</system.webServer>
</location>
</configuration>
Source:
https://stackoverflow.com/a/54702411/3850405

HTTP 500.19 – configuration data is invalid

I created web service application on .net Core 2.2, it works fine on VS IIS Express, but windows server 2012 IIS 8 it throwing error :
The requested page cannot be accessed because the related configuration data for the page is invalid
I checked config file which was generated in published version and it was :
<?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=".\WebServices.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="InProcess" />
</system.webServer>
</location>
</configuration>
<!--ProjectGuid: 2ffcb152-3fb6-43b8-aa45-784eed3432bf-->
I checked it in online validator and it was ok, so i have no clue.

httphandler in asp.net never gets called

I have a web application running in .net framework 2.0 and hosted on IIS 7.5. The app pool is running in classic mode. I want to intercept all the requests containing .txt files. Below is my entry in web.config
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<handlers>
<add name="NES.HiLo.Security.CommunityResource, NES.HiLo.Security" verb="*" path="*.txt" type="NES.HiLo.Security.CommunityResource, NES.HiLo.Security" />
</handlers>
</system.webServer>
<httpHandlers>
<add verb="*" path="*.txt" type="NES.HiLo.Security.CommunityResource, NES.HiLo.Security" />
</httpHandlers>
When I m making requests for URL like
http://local.mysite.com/media/CLT/ResourceUploads/1000277/Test1.txt
the handler never kicks in, the control never comes inside the code in the handler.
Any ideas what I m missing? thanks
According to the MSDN example of registering handler in IIS 7.0 in classic mode, you are missing a couple of attributes:
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<handlers>
<add name="CommunityResourceHandler" verb="*" path="*.txt"
type="NES.HiLo.Security.CommunityResource, NES.HiLo.Security"
modules="IsapiModule"
scriptProcessor="FrameworkPath\aspnet_isapi.dll"
resourceType="File" />
</handlers>
</system.webServer>
<httpHandlers>
<add verb="*" path="*.txt" type="NES.HiLo.Security.CommunityResource, NES.HiLo.Security" />
</httpHandlers>

Using images on Web Applications and Visual Studio for ASP.NET MVC

I am developing an ASP.NET MVC applications with MS Visual Studio 2008 SP1.
My project structure is the default one:
Project |-Content |-css |-img |-Models |-Views
|-Controllers
The thing is, I am able to access all the content placed under Content directory provided the file is included in the project. On the other hand, if I happen to have an image (I.E. an image uploaded by the user) that's on the right physical directory (Project\Content\img) but is not included in the project, I keep getting a 404 error when I access them with a browser.
I think my URL is correct:
http://localhost:1260/Content/img/my_image.jpg
And I do have a file under Project\Content\img\my_image.jpg.
What can be wrong? Am I forced to include all the files on the project? I don't think so, because that would mean that I can't have images uploaded and saved by the web users this way.
Thanks a lot.
If you're hosting your project with IIS 7, you must add he content-type in IIS 7(Handler Mapping). But if you're hosting your project with the Asp.net Developer Server, it's not required.
Using the following code in web.config file
<configuration>
<system.webServer>
<handlers>
<add name="css mapping" path="*.css" verb="*" type="System.Web.StaticFileHandler" resourceType="Unspecified" preCondition="integratedMode" />
<add name="js mapping" path="*.js" verb="*" type="System.Web.StaticFileHandler" resourceType="Unspecified" preCondition="integratedMode" />
<add name="gif mapping" path="*.gif" verb="*" type="System.Web.StaticFileHandler" resourceType="Unspecified" preCondition="integratedMode" />
<add name="jpg mapping" path="*.jpg" verb="*" type="System.Web.StaticFileHandler" resourceType="Unspecified" preCondition="integratedMode" />
<add name="png mapping" path="*.png" verb="*" type="System.Web.StaticFileHandler" resourceType="Unspecified" preCondition="integratedMode" />
</handlers>
</system.webServer>
</configuration>

Categories