Fix: error CS0234: The type or namespace name ‘Helpers’ does not exist in the namespace ‘System.Web’, when using multiple virtual IIS web applications

I have a ASP .NET 4.5.2 MVC web application running on an IIS website and I wanted to run a separate ASP .NET 4.5.2. web api application under the MVC web site.

Both projects worked just fine, when hosting them as separate IIS websites, but when the web api was “mounted” as virtual web application under the MVC website I was getting the errors below, when hitting the web api application:

error CS0234: The type or namespace name 'Helpers' does not exist in the namespace 'System.Web' (are you missing an assembly reference?)

error CS0234: The type or namespace name 'Mvc' does not exist in the namespace 'System.Web' (are you missing an assembly reference?)

Line 150:    <pages controlRenderingCompatibilityVersion="4.0">
Line 151:      <namespaces>
Line 152:        <add namespace="System.Web.Helpers" />
Line 153:        <add namespace="System.Web.Mvc" />
Line 154:        <add namespace="System.Web.Mvc.Ajax" />

So I was hitting the web api, but got an error on the parent MVC web application???

Turns out, I had to remove these namespaces in the web api web.config, because those dll’s are not in the web api project.

Adding the following lines to the web.config of the web api project, solved the errors.

<configuration>

<system.web>

<pages controlRenderingCompatibilityVersion="4.0">

      <namespaces>

         <clear/>

      </namespaces>

    </pages>

Fixing errors CS1525 and CS1003 in MSBuild

When building a Microsoft Visual Studio 2017 solution that uses C#6 and C#7 features from the command line (PowerShell), I was getting the errors:

MyClass.cs(845,112): error CS1525: Invalid expression term ‘decimal’ [Web.csproj]
MyClass.cs(845,120): error CS1003: Syntax error, ‘,’ expected [Web.csproj]
MyClass.cs(870,116): error CS1525: Invalid expression term ‘decimal’ [Web.csproj]
MyClass.cs(870,124): error CS1003: Syntax error, ‘,’ expected [Web.csproj]

This was caused by using the wrong version of MSBuild.

I used "C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" after switching to

"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\MSBuild.exe" the problem was resolved.

Fixing bug in kendo grid row cancel, when inline editing is used.

I had a strange problem in Kendo grid, when a the last row was canceled the values of the first row were shown in the last row.

The first fix was adding a cancel even handler:

cancel: function (e) {
                     this.cancelChanges();
                 }

This fixed the bug, but introduced an other one.

Now rows would persist the canceled values.

To fix both problem I changed the event handler to:

cancel: function (e) {
      this.cancelChanges();
}

I used kendo 2017.1.118

Visual Studio 2017 – How to fix: Unable to start debugging on the web server.

When I first started Visual Studio 2017 after a clean installation I got the error:

Unable to start debugging on the web server. IIS does not list a web site that matches the launched URL.

When debugging a new asp.net project.

Turns out I was not running Visual Studio 2017 as Administrator.

To fix this see:

https://olivierpaes.wordpress.com/2016/06/26/unable-to-start-debugging-on-the-web-server-iis-does-not-list-a-web-site-that-matches-the-launched-url/

or

http://stackoverflow.com/questions/10716956/iis-does-not-list-a-website-that-matches-the-launch-url

A very simple and unsafe :-), self-signed, CORS https node.js dev stub service in TypeScript


const https = require("https"); const fs = require("fs"); // To create the key.pem and cert.pem files for dev, use opensll: // openssl req -newkey rsa:2048 -new -nodes -x509 -days 3650 -keyout key.pem -out cert.pem // // Cert and key are created for hosheader "stub.service.am.dev". // Make sure the hosts file on windows contains: // 127.0.0.1 stub.service.am.dev const options = { key: fs.readFileSync("./key.pem"), cert: fs.readFileSync("./cert.pem") }; const port = 4433; https.createServer(options, function (req: any, res: any) { // Allow calls from all domains, for all methods ans request headers. res.setHeader("Access-Control-Allow-Origin", "*"); res.setHeader("Access-Control-Allow-Credentials", true); res.setHeader("Access-Control-Allow-Methods", "*"); res.setHeader("Access-Control-Allow-Headers", "*"); res.end(`Request received on server. Path Hit: ${res.url}`); }).listen(port, function() { console.log(`Stub service listing on ${port}`); });


Just enter https://stub.service.am.dev:4433 and it should respond with:

Request received on server. Path Hit: undefined

Fix in IE – Angular 1.6.1 Disabling automatic bootstrap. <script> protocol indicates an extension, document.location.href does not match.

When using angular 1.6.1 in IE9, IE10, IE11, I was getting the error:


Disabling automatic bootstrap. <script> protocol indicates an extension,

document.location.href does not match.


This seemed to be an 1.5.x issue, that was fixed in 1.5.11, but I was getting the error in 1.6.1.

To fix the error I switched from automatic bootstrapping (ng-app) to manual bootstrapping.

So I changed: <html xmlns:ng="http://angularjs.org" id="ng-app" ng-app=”myapp">

to: <html>

And after my module declaration:

angular.module('myapp', []);

angular.element(document).ready(function () {
angular.bootstrap(document, ['myapp']);
});

Align radio buttons with label on one line

Use relative positioning for the input element and correct the top position of the input, based on the line-height of the element containing the input element.

image

<!DOCTYPE html>
< html>
< head>
    <meta charset="UTF-8">
    < title>Align radio button with label on one line</title>
    <link rel="icon" href="data:;base64,iVBORw0KGgo=">
   
    <!–<link rel="stylesheet" href="plain.css">
    <script type="text/javascript" src="plain.js"></script>–>
    <style>
        .radio-container {
            box-sizing: border-box;
            font-family: ‘Open Sans’, sans-serif;
            font-size: 13px;
            line-height: 30px;
            margin: 0;
             outline: 0;
            overflow: hidden;
            padding: 0;
        }

        .radio-container input {
             box-sizing: border-box;
            margin: 0;
            outline: 0;
            padding: 0;
            position: relative;
            top: 9px;
            vertical-align: top;
         }
    </style>
< /head>
< body>
    <h1>Align radio button with label on one line</h1>
    <div class="radio-container">
         <input name="red" type="radio" value="red" checked="checked">
        red
        <input name="green" type="radio" value="green">
        green
        <input name="blue" type="radio" value="blue">
        blue
    </div>
< /body>
< /html>