Dotless HttpHandler with VS2013 Preview - less

I have just installed the Visual Studio 2013 preview and run up my site. I've noticed that the less files which are used in my site are not being correctly transformed to css and are coming down as blank CSS files.
It appears something is going wrong inside the dotless httphandler as when I force minification for the bundle everything works correctly.
web.config
<section name="dotless" type="dotless.Core.configuration.DotlessConfigurationSectionHandler, dotless.Core" />
...
<httpHandlers>
<add path="*.less" verb="GET" type="dotless.Core.LessCssHttpHandler, dotless.Core" />
</httpHandlers>
...
<handlers>
<add name="dotless" path="*.less" verb="GET" type="dotless.Core.LessCssHttpHandler,dotless.Core" resourceType="File" preCondition="" />
</handlers>
The issue appears to go away if I force minification eg. System.Web.Optimization.BundleTable.EnableOptimizations = false; which suggests something is different in the way it processes the HTTP handler

Try putting handleWebCompression="false" in the configuration for dotless (in the web config)
<dotless minifyCss="false" cache="true" web="false" handleWebCompression="false" />

Related

No transpilation on IIS production server

First off, a lot of this technology is new to me, so I apologize for the noob question. Also, this is my first post to SO (after years of reading), so forgive the formatting.
I have a web application that I am running via MSVS 2017. I am writing my front end with React.js. After installing the appropriate packages via nuget, I have something that works when I run both the debug and release versions on my local dev machine (using iisexpress).
However, after I commit my source changes, and it gets pushed to the test server (IIS), the app runs fine. But, the JSX files that are returned from the test server are not transpiled. I just get the raw JSX file. Whereas, on my local machine, the returned file is transpiled.
I have a ReactConfig.cs file with a single static Configure method, where I have a call to add my JSX file via ReactSiteConfiguration.Configuration.AddScript, but that appears to be unnecessary because I still get a transpiled result even when it is commented out. At the top of my ReactConfig.cs file I have seomthing similar to:
[assembly: webActivatorEx.PreApplicationStartMethod(typeof(MyApp.Api.Controllers.MyController), "AutoMapperStart")]
So, then I am left with the question of how is the transpiling occuring on my dev machine, but not the deployment machine.
In my web.config file, I have tried both:
<httpHandlers>
<add verb="GET" path="*.jsx" type="React.Web.BabelHandlerFactory, React.Web" />
</httpHandlers>
and
<remove name="Babel" /><add name="Babel" verb="GET" path="*.jsx" type="React.Web.BabelHandlerFactory, React.Web" preCondition="integratedMode" /></handlers>
But neither seems to make a difference on the deployed server.
If anyone has suggestions of what I should look at next, it would be greatly appreciated.
Update:
I notice the relevant item that is allowing my dev environment to do the transpilation is the second code section above in my web.config file. However, that I don't see the same lines on the server. Are web.config file typically 'hand edited' per deployment, perhaps?
So, here is what I eventually figured out that worked for me.
First, yes, the web.config file is deployed with as a template. And then hand configured as necessary.
Second, and more importantly, there are two parts to getting the server to render JSX to pure JS.
I needed the following in the web.config file:
<system.webServer>
<handlers>
<remove name="Babel" />
<add name="Babel" verb="GET" path="*.jsx"
type="React.Web.BabelHandlerFactory, React.Web"
preCondition="integratedMode"/>
</handlers>
</system.webServer>
And finally, in the assemblyBinding section:
<dependentAssembly>
<assemblyIdentity name="JavaScriptEngineSwitcher.Core" publicKeyToken="c608b2a8cc9e4472" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.4.9.0" newVersion="2.4.9.0" />
</dependentAssembly>

.net Core API not working on IIS

I'm new to this .NET Core stuff and this is the first time I've tried to deploy one of these.
The project is an API for an Angular front end I'm building and takes HTTP requests and returns JSON. When I run it in Visual Studio on my box it is all fine. I'm running VS2017 and have .NET Core 2.0.0 installed.
I publish to a folder on the web server and it all seems to work fine, but when I try to access the API I get a 404 not found error. The server is running .NET 2.0.6 (I tried to get 2.0.0 but couldn't find it in the Hosting Bundle Installer.
If I delete the web.config the HTML file will then show up, but obviously the API doesn't work. But as the HTML file shows up there is no issue with permissions and access. There's nothing in the Event Viewer. I've also tried turning on the logging in the web.config, but it doesn't log... probably not getting far enough to.
Web config looks like this.
<?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=".\RawMaterialsSystem.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
</system.webServer>
</configuration>
<!--ProjectGuid: f01b1621-2ced-4ad2-9ae6-004e03b0e043-->`
STEP 1: Change your web.config file to this
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<!--
Configure your application settings in appsettings.json. Learn more at http://go.microsoft.com/fwlink/?LinkId=786380
-->
<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" />
</system.webServer>
</configuration>
STEP 2:
In visual studio, right click the .net core app project and select "Publish"
Then publish it as a folder under bin\Release\netcoreapp2.0\publish
STEP 3:
In IIS --> Sites --> Right click on YourSite --> Under "Manage Website" select "Advanced Settings"
Make sure the "Physical Path" you are pointing to is the "publish" folder as the app directory, and not the "netcoreapp2.0" folder

Cannot get glyphicons-halflings-regular.woff2

I am getting this error messages - cant load glyphicons... Why?
Below is the folder structure of my code
Simply you need to add woff and woff2 MIME types to your web.config or add them directly in your webserver config file
<system.webServer>
<staticContent>
<remove fileExtension=".woff" />
<remove fileExtension=".woff2" />
<mimeMap fileExtension=".woff" mimeType="application/font-woff" />
<mimeMap fileExtension=".woff2" mimeType="application/font-woff" />
</staticContent>
</system.webServer>
Sorry I mistook your dark theme for visual studio and I thought you was using ASP.NET
I leave this code snippet because the same problem could be faced by ASP.NET users

ImageResizer works when testing with Visual Studio - not working on production?

I have ImageResizer installed via NuGet which is working fine when I run the ASP.Net MVC website from Visual Studio. I can get to the /resizer.debug page and it says all is well.
When I come to publish the site from Visual Studio to the main IIS instance on the same machine, ImageResizer does not work and when I browse to /resizer.debug I get a 404 Not Found error.
I have published the web.config and verified all the image resizer components are in there. Eg:
<httpModules><add name="ImageResizingModule" type="ImageResizer.InterceptModule" /></httpModules></system.web>
The ImageResizer dlls are also in the /bin directory.
However, nothing is happening and the debug page will not display.
Is there something that needs to be done to configure ImageResizer on IIS7 when publishing the project?
It appears that you only configured it for IIS Classic, not IIS7 Integrated mode. There must be a <system.webServer> element with the module installed.
From the installation guide:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="resizer" type="ImageResizer.ResizerSection,ImageResizer" requirePermission="false" />
</configSections>
<resizer>
<!-- Unless you (a) use Integrated mode, or (b) map all requests to ASP.NET,
you'll need to add .ashx to your image URLs: image.jpg.ashx?width=200&height=20 -->
<pipeline fakeExtensions=".ashx" defaultCommands="autorotate.default=true"/>
<plugins>
<add name="DiskCache" />
<!-- <add name="PrettyGifs" /> -->
<!-- <add name="SimpleFilters" /> -->
<!-- <add name="S3Reader" /> -->
</plugins>
</resizer>
<system.web>
<httpModules>
<!-- This is for IIS7/8 Classic Mode and Cassini-->
<add name="ImageResizingModule" type="ImageResizer.InterceptModule"/>
</httpModules>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules>
<!-- This is for IIS7/8 Integrated mode -->
<add name="ImageResizingModule" type="ImageResizer.InterceptModule"/>
</modules>
</system.webServer>
</configuration>

How to publish an MVC 6 website in IIS with multiple apps in the src folder

When I try to publish an asp.net 5 website with multiple web apps in the 'src' folder. It works okay in klr but If I run it under IIS, I get this error:
Failed to resolve the following dependencies for target framework 'Asp.Net,Version=v5.0'
Here is a very basic simple project attached that you might want to run under IIS.
http://www.filedropper.com/iissampleapp
Update: updating my question as requested.
In the attached project, I just right click on "IISSampleApp" and click publish. Visual studio creates files on local file system, which I then try to run under IIS. After publish, both of the web apps reside under src folder as src\IISSampleApp and src\SubApp. The IISSampleApp is the main app that should run as website, and it just references a class DateClass from SubApp.
I have created this sample project to get the answer, my actual project have similar structure and I get the same error.
I have uploaded the Precompiled version of the project here: http://www.filedropper.com/precompilediissample
Below is my generated web.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="kpm-package-path" value="..\approot\packages" />
<add key="bootstrapper-version" value="1.0.0-beta3" />
<add key="runtime-path" value="..\approot\packages" />
<add key="kre-version" value="1.0.0-beta3" />
<add key="kre-clr" value="clr" />
<add key="kre-app-base" value="..\approot\src\IISSampleApp" />
</appSettings>
</configuration>
edit the web.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="kpm-package-path" value="..\approot\packages" />
<add key="bootstrapper-version" value="1.0.0-beta3" />
<add key="runtime-path" value="YOUR-RUNTIME-BASE-PATH\.k\runtimes" />
<add key="kre-version" value="1.0.0-beta3" />
<add key="kre-clr" value="clr" />
<add key="kre-app-base" value="..\approot\src\YOURPROJECT" />
</appSettings>
</configuration>
and set the security policy for \approotand \wwwroot
update: updating the answer after question's update
That just can't work like this because the kpm bundle command packages website as website and not as class library and you have 2 Startup class which is no good. If you want to share code between 2 website create a class library.