Adding Silverlight MimeType using adsutil - silverlight

I have a script that creates an app pool, web site - and then I want to use adsutil to add the .xap MimeType.
I see this:
cscript adsutil.vbs set W3SVC//Root/MimeMap “.extension,mimetype”
However, since I am creating the web site in the same script I will not know the ID.
Would anyone know how to do this with adsutil?
Thanks,
Rich

You could always add the MimeType using web.config instead:
<configuration>
<system.webServer>
<staticContent>
<mimeMap fileExtension=".xaml" mimeType="application/xaml+xml" />
<mimeMap fileExtension=".xap" mimeType="application/x-silverlight-app" />
<mimeMap fileExtension=".xbap" mimeType="application/x-ms-xbap" />
</staticContent>
</system.webServer>
</configuration>

Related

Hosting backend files onto IIS

I'm trying to upload my website onto the web. I have two folders for holding my front-end React files and another for the back-end files that uses Nodejs, cors, and express. It also has my API and middleware.
The front-end pages have already been uploaded onto my IIS and port forwarded with my router, so I can access that anywhere with my IP. But it doesn't function well without my backend files, how can I host the backend files as well and make them work together?
I am getting a headache doing this, does anyone know how to do this??
Thanks in advance.
As far as I know, if you want to host node.js application, you should firstly install the node.exe and the a build of iisnode.
node.exe
iisnode
After installed the IIS nodes, you could set up samples, from the administrative command prompt call %programfiles%\iisnode\setupsamples.bat.
Then you could go to http://localhost/node to see the example.
The next step is to deploy the node.js application inside one iis web application.
Lastly, you should create or modify the web.config to use the iisnode modules.
For example,
<configuration>
<system.webServer>
<handlers>
<add name="iisnode" path="app.js" verb="*" modules="iisnode" />
</handlers>
<rewrite>
<rules>
<rule name="mysite">
<match url="/*" />
<action type="Rewrite" url="app.js" />
</rule>
</rules>
</rewrite>
<defaultDocument>
<files>
<add value="app.js" />
</files>
</defaultDocument>
</system.webServer>
More details, you could refer to below article:
https://www.hanselman.com/blog/InstallingAndRunningNodejsApplicationsWithinIISOnWindowsAreYouMad.aspx

.NetCore React JS: How To Prevent .gltf File From Being Routed?

In debug mode my code is working fine.
window.BABYLON.SceneLoader.ImportMesh(
"",
"/assets/logo/3D/",
"logo.gltf",
that.scene,
function (meshes) { ..... });
My .gltf 3D asset is stored in public/assets/logo/3D with the name logo.gltf. I am using .NetCore as the web server.
Somehow whenever the loader requests .gltf file, it returns html. It suppose to return json (gltf). Image files like .jpg, '.png', etc... are fine.
I have specify the mime type for .gltf in my web.config file:
<system.webServer>
<staticContent>
<remove fileExtension=".gltf" />
<mimeMap fileExtension=".gltf" mimeType="model/gltf+json" />
</staticContent>
</system.webServer>
Here is the screenshot:
It retrieves as content-type: text/html. It suppose to be model/gltf+json.
How can I load the file safely?
You can configure ASP.NET Core to return correct Content-Type by adding your MIME type to file provider. In Startup add StaticFileOptions argument with extended content type provider to your app.UseStaticFiles() call
var provider = new FileExtensionContentTypeProvider();
provider.Mappings[".gltf"] = "model/gltf+json";
app.UseStaticFiles(new StaticFileOptions
{
ContentTypeProvider = provider
});
If you want to serve such static files via IIS you need to add a static file processing module before ASP.NET Core pipeline
web.config
<system.webServer>
<handlers>
<!-- added staticGltf handler to serve .gltf files -->
<add name="staticGltf" path="*.gltf" verb="*" modules="StaticFileModule" resourceType="File" requireAccess="Read" />
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore you_config_here />
<staticContent>
<remove fileExtension=".gltf" />
<mimeMap fileExtension=".gltf" mimeType="model/gltf+json" />
</staticContent>
</system.webServer>
But in this case you might need to address possible issues with routes (such as ASP.NET Core is configured to search files in wwwroot folder but IIS will search in app root instead) and insufficient file permissions.
#Alexander answer is the correct answer. Here is my Startup file if anyone wants to know.
Inside the Configure method:
var provider = new FileExtensionContentTypeProvider();
provider.Mappings[".gltf"] = "model/gltf+json";
var staticFileOpt = new StaticFileOptions()
{
ContentTypeProvider = provider
};
app.UseStaticFiles(staticFileOpt);
app.UseSpaStaticFiles(staticFileOpt);
There is UseStaticFiles() and UseSpaStaticFiles(). I am using ReactJS as the SPA framework, that is why I need UseSpaStaticFiles() too.

Angular translate works on VS locally but not on the server why?

I have a test site that works when i run it on visual studio. it translate perfectly.
but on the server it does'nt. i know angularits there because i'm using ui.router and its working the link and everything but not the translate.
again on vs works.
what can it be? thanks
it only shows my prefixes http://m3rca.azurewebsites.net
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<staticContent>
<mimeMap fileExtension=".json" mimeType="application/json" />
</staticContent>
</system.webServer>
</configuration>
This solve it. thanks

Trying to Programmatically Expire the HTTP Response Headers

Our Team is building a C# project with a Silverlight module. We deploy to a Windows 2008 with IIS 7. I’m trying to Programmatically Expire the HTTP Response Headers Associated with a Folder called ClientBin immediately. I know how to do it manually through IIS Manager. ( Basically, I go to the HTTP Response Headers Section of the folder or file that is of interest, and then I use "Set Common Headers...." to expire immediately.) However, we will be Redeploying to IIS a number of times, and I want to ensure that it is programmatically done because it’s a headache to keep Reconfiguring all the time.
Should I do it from the C# code of my project or is it better practice to do it using WMI scripting?
#kev and #jeff-cuscutis have provided the ways to configure expiration of the HTTP Response Headers using XML configuration in the web.config file of a ASP.NET application
How to configure static content cache per folder and extension in IIS7?
ou can set specific cache-headers for a whole folder in either your root web.config:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<!-- Note the use of the 'location' tag to specify which
folder this applies to-->
<location path="images">
<system.webServer>
<staticContent>
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="00:00:15" />
</staticContent>
</system.webServer>
</location>
</configuration>
Or you can specify these in a web.config file in the content folder:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<staticContent>
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="00:00:15" />
</staticContent>
</system.webServer>
</configuration>
I'm not aware of a built in mechanism to target specific file types.
You can do it on a per file basis. Use the path attribute to include the filename
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<location path="YourFileNameHere.xml">
<system.webServer>
<staticContent>
<clientCache cacheControlMode="DisableCache" />
</staticContent>
</system.webServer>
</location>
</configuration>

IIS7: Cache Setting Not Working... why?

My IIS7 web.config is set to the following with a folder of static assets (not within an ASP.NET app or anything):
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<staticContent>
<clientCache cacheControlCustom="public" cacheControlMode="UseMaxAge" cacheControlMaxAge="500.00:00:00" />
</staticContent>
<httpProtocol allowKeepAlive="false" />
</system.webServer>
</configuration>
When I try to access a Silverlight .XAP file, I expect IIS to tell the browser that it can be cached for 500 days.
However, this is the cache header:
Cache-Control: no-cache,public,max-age=43200000
Why is IIS still adding no-cache to this header with the above configuration file?
You need to configure IIS to treat XAP as static content. Try this:
<configuration>
<system.webServer>
<staticContent>
<mimeMap fileExtension=".xaml" mimeType="application/xaml+xml" />
<mimeMap fileExtension=".xap" mimeType="application/x-silverlight-app" />
<mimeMap fileExtension=".xbap" mimeType="application/x-ms-xbap" />
</staticContent>
</system.webServer>
</configuration>

Resources