Archive

Archive for February, 2015

MVC Razor View escape character

February 13th, 2015 No comments

The Problem

You want to use your model or some code to append a variable inline with a string.
Assume you want to create a URL with a dynamic element like:

http://appserver-dev.domain.com

where -dev will be an appsetting accessed in razor from @Settings.Default.URLSuffix

When you add the @Settings value in like so;

http://appserver@Settings.Default.URLSuffix.domain.com

it treats the @Settings.Default.URLSuffix as a text string, outputting “http://appserver@Settings.Default.URLSuffix.domain.com” not “http://appserver-dev.domain.com” as you were hoping. What is the escape character?

The Solution

@@ is the escape sequence.. so that should be easy..

http://appserver@@Settings.Default.URLSuffix.domain.com

The problem now is it treats the .domain.com as part of the code and is not happy because a string object does not have .domain.com methods.

http://appserver@@Settings.Default.URLSuffix;.domain.com

Add a semi-colon to end the code and that is the problem solved.

VN:F [1.9.22_1171]
Rating: 0.0/10 (0 votes cast)

Categories: MVC, Uncategorized Tags:

IIS Express and windows authentication

February 13th, 2015 No comments

How to control the IIS Express Authentication settings

To set the windows authentication parameters for you MVC applicaiton there are two ways to do this .

  1. On a per project basis, by going to the properties of the web app, F4, and setting the windows authentication to on or off; or
  2. Globally for the entire computer.
    • go to the following path, %HemePath%\Documents\IISExpress\config
    • edit the “applicationhost.config” file
    • find the line
    • Change the value as required and then save
VN:F [1.9.22_1171]
Rating: 0.0/10 (0 votes cast)

Categories: MVC, Uncategorized Tags: