Graphics missing when deploying to azure - asp.net-mvc

I just deployed my first MVC5 application to azure, and got everything to work, except that it is not showing graphics. On my development machine this works.
My graphics are in a folder ~/Content/Graphics, and this is the part of the _Layout.cshtml that references one,
<img src="#Url.Content("~/content/graphics/EluciusSoft_Logo.svg")" style="height:50px">
I know that the files are on the server, though, since I checked it with WebMatrix. Why are they not displaying?
EDIT: The browser console error message is the following:
Failed to load resource: the server responded with a status of 404
(Not Found)
Here is a screenshot of the site directory using WebMatrix.

If the webserver hasn't been configured with the MIME type for SVG, then it will return a 404 error when you try and access it. You can define the MIME type in your application's web.config:
<configuration>
<system.webServer>
<staticContent>
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
</staticContent>
</system.webServer>
</configuration>

Related

.NET 6.0 MVC App returns 404 in IIS on Windows 10

I've just refreshed an app written in .net 2.1 to .net 6.0. I worked through the errors and the site appears to compile cleanly. After I published to the server had many errors. Working through them, and standing up a full IIS install on my own machine, I now have it down to a 404 error.
When running the exe straight from the console it runs without errors.
Z:\ReportGroups>FleetLogix.ReportGroups.exe
warn: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[35]
No XML encryptor configured. Key {snip} may be persisted to storage in unencrypted form.
c:\inetpub\wwwroot\ReportGroups>FleetLogix.ReportGroups.exe
Hosting environment: Production
Content root path: c:\inetpub\wwwroot\ReportGroups
Now listening on: http://localhost:5000
Now listening on: https://localhost:5001
Application started. Press Ctrl+C to shut down.
Application is shutting down...
Web.config is
<?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=".\FleetLogix.ReportGroups.dll" forwardWindowsAuthToken="false" startupTimeLimit="3600" requestTimeout="23:00:00" stdoutLogEnabled="false" hostingModel="inprocess" stdoutLogFile=".\logs\stdout" />
</system.webServer>
</location>
</configuration>
Looking through Event Viewer, there's nothing of note. System nothing for IIS, IIS-Configuration and IIS-Admin are empty.
Edit 2021-11-22
It took a morning, but I have Request Tracing installed. For those on windows 10, just go to Add Features > IIS > Health > Tracing. Don't believe the server 2012 pages. Below is a screenshot:
The actual xml and xslt were quite verbose.
I have reinstalled the Hosting package as administrator, just in case. The version installed was dotnet-hosting-6.0.0-win.exe. That didn't fix it. IIS was stopped/started at server level as well.
At the moment it looks like the handlerv2 is missing?
If any other logs or config are required please let me know
"At the moment it looks like the handlerv2 is missing?" is incorrect.
The correct interpretation of the FRT log is that ASP.NET Core module (handler configured in your web.config) runs fine, and decides that no routing rule yields a result for the incoming URL http://localhost/ReportGroups. Thus, it returns 404 as designed.
It is your responsibility to review IIS configuration (site/app) as well as your source code on routing to see what should be the right URL to use to access the target pages. And unless you share those parts, discussion on this question cannot move forward.

Asp.net MVC .properties file is not loading from View(cshtml)

I am doing an asp.net mvc project.In the view(cshtml) page, I have to load several external resources with several extensions.All the resources with extensions .css,.js are loading.But, I have a file has the extension .properties which is not being loaded in same process.I don't know how to solve it.
The error is -
Failed to load resource: the server responded with a status of 404 (Not Found)
My project structure
-Project
-Areas
-Two
-Library
-pdfjs-1.5.188-dist
-web
-locale
-locale.properties
I am using following line to load locale.properties file i the view -
<link rel="resource" type="application/l10n" href="~/Areas/Two/Library/pdfjs-1.5.188-dist/web/locale/locale.properties">
The given path is 100% correct.But, on that path resource is not being found.
Can anybody say me what is the problem and how can I solve this???
You have to add the .properties file extension to your web.config file:
<system.webServer>
<staticContent>
<remove fileExtension=".properties" />
<mimeMap fileExtension=".properties" mimeType="text/plain" />
</staticContent>
</system.webServer>

UmbracoAzureBlobStorage - Files lost after some times Using Umbraco 7

I have a project that uses a combination of these tools:
==================================
Azure website
Azure Blob
Azure CDN
UmbracoAzureBlobStorage - 1.0.10.5 - https://github.com/idseefeld/UmbracoAzureBlobStorage
WindowsAzure.Storage - 4.3.0
Umbraco - 7.2.5 assembly: 1.0.5610.18894
idseefeld.de.UmbracoAzure - 1.0.0.0
https://our.umbraco.org/projects/backoffice-extensions/azure-blob-storage-provider/
==================================
config/FileSystemProviders.config
<FileSystemProviders>
<!-- Media -->
<Provider alias="media"
type="idseefeld.de.UmbracoAzure.AzureBlobFileSystem, idseefeld.de.UmbracoAzure">
<Parameters>
<add key="containerName" value="media" />
<add key="rootUrl" value="http://az739977.vo.msecnd.net/" />
<add key="connectionString" value="DefaultEndpointsProtocol=https;AccountName=XXX;AccountKey=XXX" />
</Parameters>
</Provider>
</FileSystemProviders>
==================================
The file upload is working as expected at start. But after sometime, and of course few uploads, it looks like our files are deleted from the blob and the CDN cannot serve them anymore.
Is there something I'm missing? I have almost the same configuration in another project and it's working as expected. I tried reinstalling the whole thing but the problem occurs everytimes.
https://our.umbraco.org/projects/backoffice-extensions/azure-blob-storage-provider/ show us configuration that point directly to the blob, not the CDN as I do. Should I take a look at this?
Uninstall-Pacakge UmbracoAzureBlobStorage
Uninstall-Package idseefeld.de.UmbracoAzure
Install-Package UmbracoAzureBlobStorage
Solved the problems. The project referenced the "idseefeld" DLL. It was kinda weird.

Elmah.MVC working under IIS Express but not IIS 7.5

I'm trying to get Elmah working under ASP.NET MVC and I thought I had.
I used the very convenient Elmah MVC project which automatically setup my web.config file.
Now if I run the project under IIS Express then Elmah works just perfectly.
I can access it with the correct Authorisation and the logs are stored in my SQL Database.
However when I try and run it under IIS 7.5 I get an:
An HTTP 500.19 Internal Server error
Module IIS Web Core
Notification BeginRequest
Handler Not yet determined
Error Code 0x800700b7
Config Error Cannot add duplicate collection entry of type 'add' with unique key attribute 'name' set to 'ErrorLog'
Config File web.config
Config Source:
111: <modules>
112: <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" />
113: </modules>
I'm baffled as to why this might be. As a test I've created a brand new clean MVC project and it reacts exactly the same way.
do a
<remove name="ErrorLog"/>
before the
<add />
to get rid of any default defined entries named ErrorLog in the modules section of your web.config file.

How to bind to an assembly outside the /bin folder

I have a web-site named CCESD set up in IIS7; my application root folder is D:\Websites\CCESD\CCESD. I also have a folder holding third-party assemblies (not all of which are strong-named) at D:\Websites\CCESD\CCESD\BinCommon: this is because I also have many other web applications under this root site in IIS that will share the DLLs, some of which are unmanaged code and so can't go in the GAC. My web.config file looks like this:
<compilation defaultLanguage="c#" debug="true" targetFramework="4.0">
<assemblies>
...
<add assembly="Telerik.Web.UI, Version=2012.1.288.40, Culture=neutral, PublicKeyToken=121FAE78165BA3D4" />
</assemblies>
</compilation>
...
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="BinCommon" />
</assemblyBinding>
</runtime>
However, when I try to run the web application, I get the following error (after enabling assembly-binding error logging):
Parser Error Message: Could not load file or assembly 'Telerik.Web.UI,
Version=2012.1.288.40, Culture=neutral,
PublicKeyToken=121fae78165ba3d4' or one of its dependencies. The
system cannot find the file specified.
Source File: D:\Websites\CCESD\CCESD\web.config Line: 144
Assembly Load Trace: The following information can be helpful to
determine why the assembly 'Telerik.Web.UI, Version=2012.1.288.40,
Culture=neutral, PublicKeyToken=121fae78165ba3d4' could not be loaded.
Assembly manager loaded from:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
Running under executable c:\windows\system32\inetsrv\w3wp.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: User = IIS APPPOOL\CCESD
LOG: DisplayName = Telerik.Web.UI, Version=2012.1.288.40, Culture=neutral,PublicKeyToken=121fae78165ba3d4 (Fully-specified)
LOG: Appbase = file:///D:/Websites/CCESD/CCESD/
LOG: Initial PrivatePath = D:\Websites\CCESD\CCESD\bin Calling
assembly : (Unknown). ===
LOG: This bind starts in default load context.
LOG: Using application configuration file:
D:\Websites\CCESD\CCESD\web.configLOG: Using host configuration file:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet.config
LOG: Using machine configuration file from
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Post-policy reference: Telerik.Web.UI, Version=2012.1.288.40,
Culture=neutral, PublicKeyToken=121fae78165ba3d4
LOG: Attempting download of new URL
file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary
ASP.NET Files/root/e11e9098/9e133b72/Telerik.Web.UI.DLL.
LOG: Attempting download of new URL
file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary
ASP.NET
Files/root/e11e9098/9e133b72/Telerik.Web.UI/Telerik.Web.UI.DLL.
LOG: Attempting download of new URL
file:///D:/Websites/CCESD/CCESD/bin/Telerik.Web.UI.DLL.
LOG: Attempting download of new URL
file:///D:/Websites/CCESD/CCESD/bin/Telerik.Web.UI/Telerik.Web.UI.DLL.
LOG: Attempting download of new URL
file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary
ASP.NET Files/root/e11e9098/9e133b72/Telerik.Web.UI.EXE.
LOG: Attempting download of new URL
file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary
ASP.NET
Files/root/e11e9098/9e133b72/Telerik.Web.UI/Telerik.Web.UI.EXE.
LOG: Attempting download of new URL
file:///D:/Websites/CCESD/CCESD/bin/Telerik.Web.UI.EXE.
LOG: Attempting download of new URL
file:///D:/Websites/CCESD/CCESD/bin/Telerik.Web.UI/Telerik.Web.UI.EXE.
I have checked that the file exists and the version and public-key information are correct. What am I doing wrong?
I found it eventually; in the end, it was down to this:
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
My project began life in Visual Studio 2005; hence the xmlns attribute shown above was present in the containing element of my web.config file. Removing it fixed the problem and now my assemblies are being loaded correctly.
Googling reveals that the xmlns attribute is there to enable intellisense in Visual Studio (which indeed it does): it says nothing about having any effect on loading assemblies, so this is all a little strange (not to mention annoying). Still, now it's working.

Resources