Windows 2012 Hosting - MVC 6 and SQL 2014 BLOG

Tutorial and Articles about Windows Hosting, SQL Hosting, MVC Hosting, and Silverlight Hosting

JSON Hosting on Windows Server:: How to Add JSON Handler in IIS

clock July 22, 2014 09:37 by author Ben

JSON is a text format that is completely language independent but uses conventions that are familiar to programmers of the C-family of languages, including C, C++, C#, Java, JavaScript, Perl, Python, and many others. These properties make JSON an ideal data-interchange language. JSON is very useful when developing a web application where fast, compact and convenient serialisation of data is required, however it's flexible nature is the very thing that makes it less suitable than XML for transferring data between separate systems, or storing data that will be read by 3rd parties.

JSON is built on two structures:

  • A collection of name/value pairs. In various languages, this is realized as an object, record, struct, dictionary, hash table, keyed list, or associative array.
  • An ordered list of values. In most languages, this is realized as an array, vector, list, or sequence.

These are universal data structures. Virtually all modern programming languages support them in one form or another. It makes sense that a data format that is interchangeable with programming languages also be based on these structures.

Advantages of JSON

  • Smaller message size
  • More structural information in the document
  • Can easily distinguish between the number 1 and the string "1" as numbers, strings (and Booleans) are represented differently in JSON.
  • Can easily distinguish between single items and collections of size one (using JSON arrays).
  • Easier to represent a null value
  • Easily consumed by JavaScript

Sometimes we need to create JSON in a text file with extension .json, however by default IIS 7 or any of the IIS are not configure to handle .json extension. So below is a very simple method to do that. You can apply the method on the root of IIS so .json can be handled by every site or virtual folder in the IIS or just to the specific site.

  1. Open IIS Manager
  2. Display properties for the IIS Server
  3. Click MIME Types and then add the JSON extension:
    File name extension: .json

    MIME type: application/json
  4. Go back to the properties for IIS Server
  5. Click on Handler Mappings
    Add a script map

    Request path: *.json

    Executable: C:\WINDOWS\system32\inetsrv\asp.dll

    Name: JSON

Reasons To Use IIS 7 Hosting

IIS 7 makes extending Web server functionality easier. A new integrated pipeline lets developers create custom modules that can be plugged into the IIS7’s new request-processing pipeline. Developers can write native modules with C++ or managed modules in a .NET language such as C# or Visual Basic.Net. The advanced features of the .NET Framework, combined with deep integration into the IIS 7 pipeline, lets developers create custom modules quickly and easily. Any application can leverage the .NET Role and Membership providers, which are integrated in the new IIS 7 pipeline. Existing ISAPI applications built for IIS6 will also run without modification in IIS 7’s Classic mode.

IIS 7 builds on the security and reliability established by IIS 7.0. The modular design lets you reduce the attack surface of your server by uninstalling the modules that you do not need for your application. You can also write your own modules to support your custom security requirements. New automatic application isolation adds a layer of protection to keep applications safe from each other. IIS 7’s ability to set up rules to control access to URLs and filter requests lets administrators manage access to sites, folders, and files without requiring ACLs. And admin delegation lets you assign limited administrative rights to users for specific sites instead of granting server-wide admin rights.



IIS Hosting - ASPHostPortal.com :: How to Checking and Setting up the Correct Permissions on the IIS Server

clock December 3, 2013 10:56 by author Mike

If you are using an Classic ASP, ASP.NET or PHP application on a Windows Server that requires that you write data or upload to a folder then you will need to check and if necessary change the permissions on the server so that you have write as well as read permissions on the directory and files you wish to write too.


To check or change the permissions on the server go to Windows Explorer and do the following (for NT and Win 2K users only using NTFS file system, Win XP Pro users see note at bottom):
1. Right click on the directory containing the database or text file.
2. Click on 'Properties'.
3. Choose the 'Security' tab form the dialog box window.
4. Uncheck 'Allow inheritable permissions from parent to propagate to this object', from the bottom of the dialog box.
5. Next, click on the 'Add' button at the top left of the window.

Security Properties Dialog Box

6. Next the 'Select Users or Groups' dialog box will open, highlight 'IUSR_MyComputer' account from the list by clicking on it. Where 'MyComputer' is this will be the name of your computer. 'IUSER' is the Internet Guest Account setup by default when IIS is installed on the system.

Select Users or Groups Dialog Box

7. Next click on the 'Add' button in the middle left of the dialog box. You should then see 'MyComputer\IUSER_MyComputer' appear in the box in the bottom half of the dialog box. Again where 'MyComputer' is will be the name of your computer.
9. Now click on the 'OK' button at the bottom right of the 'Select Users or Groups' dialog box.
10. You should now be back at the 'Security Properties' dialog box where the top box should now contain the 'Internet Guest Account (MyComputer\IUSER_MyComputer)'.
11. Highlight the 'Internet Guest Account (MyComputer\IUSER_MyComputer)' by clicking on it in the top box.
12. Select 'Read' and 'Write' permissions for this account by checking the boxes at the bottom of the window (If you are not to worried about security you could check all the boxes to make sure that you have no problems with permissions).

Security Properties Dialog Box

13. Next repeat all the steps above on the database or text file itself, to make sure the database or text file also has the correct permissions.



IIS Hosting - ASPHostPortal.com :: Trick Setting up Connection String with IIS Manager

clock November 27, 2013 05:27 by author Ben

The IIS Manager is the graphical user interface of IIS, Microsoft's web server. In this article I will give you a step by step guide on how to set up the connection string with IIS Manager.

1. Open IIS Manager and connect to your site. You can start it from the command prompt or Start menu.
Command prompt

  1. On your desktop, click Start > Run.
  2. Type inetmgr and click OK.

Start menu
On your desktop, click Start > Programs or All Programs > Administrative Tools > Internet Information Services (IIS) Manager.

2. Once connected, click on Connection Strings:




3. Click on Add to configure a new connection string:




4. First, add the connection string name. Make sure it is the same connection string that you use in your ASP application. Then add the server’s name and also the name of the database:
connection 45. Before saving, we have to set up the credentials to connect to your database. Set Credentials to ‘Specify Credentials‘ and then click on ‘Set…‘



6. Enter the username and password of the database that your application will be using and click ok:



7. Check that the information is correct and click on ‘Ok‘:



8. And that’s it! Your Connection String has been configured!

 

For more info please visit ASPHostPortal.com - Best Cheap and Reliable Windows ASP.NET Hosting



How To Enable .CSHTML Support In Windows Server 2012

clock October 24, 2013 12:25 by author andry

C# ("C sharp")is  HTML webpage file used by Razor, an ASP.NET view engine used for generating Web pages for a user's Web browser; similar to a standard ASP.NET webpage (.ASP or .ASPX file), but uses a slightly different syntax; runs on a Web server, which generates the HTML for the client Web browser; can be programmed with syntax highlighting.

If we build a website that contains .cshtml file, we must enable .cshtml file. At the below, there is an error message if we don’t enable .cshml file.

To enable .cshtml file on windows Server 2012, There are steps to solve that problem. Open your IIS.

Expand “server”-> “sites” and choose “domain”.  Then click on Handler Mapping.

You can't find .cshtml. After that, choose “Revert to Parent” on right tab.

Select "Yes" and Look,what the difference with the previous image.

.cshtml file are enable and available. Now browse the domain. If you still can not access and have an error. You should check the .NET version. Remember that .Cshtml file can only be run on .NET version 4 and above.

To check the .Net version, select "application pools" -> right click on "domain_name" -> "Basic settings" -> choose .Net 4 version -> "Ok".

Now you can browse your domain with .cshtml file. Here is screenshot.



Web Deploy Hosting :: ASPHostPortal.com - How to Fix “Error: An unsupported response was received. The response header ‘MSDeploy.Response’ was ” but ‘v1' was expected

clock September 23, 2013 07:32 by author Ben

When you get this error from MSDeploy: 

“Error: An unsupported response was received. The response header ‘MSDeploy.Response’ was ” but ‘v1′ was expected.

Error: The remote server returned an error: (401) Unauthorized.”

This means that you do not have access. On our newer servers web deploy is enabled from the Management tab in your website. Older servers require web deploy to be enabled for each account, so please submit a support ticket if you need it enabled.

So you can follow this step fo fix error :

1. Web Deploy package is not installed on the IIS server in question . To install find the " Web Deploy " or " Web Deploy 2.0 " from the top level IIS.Net \ Download ( for downloading all extensions ) or directly on the Web Deploy 2.0 page . Alternately if the Platform installer addin is installed one can find it through the IIS Server Manager where one can also install it and other goodies . ( The platform installer as shown below can be found in the server list and individual website or list of icons in the management section . )



2. Even if Web Deploy package is installed , the service is not running automatically . Follow these steps to find the correct service and get it running .

a. Run services.msc from the start bar or command line .

 

b. Search for the service named Web Deployment Agent Service . Once found verify it is running and also starts up automatically after a reboot .



3. Also your account may not have permissions to publish to the web site in question . In IIS Management Studio , find the website in question and the make sure your ( or other 's ) credentials are found in the IIS Manager Permission list .





ASP.NET Hosting - IIS 7.5 Hosting - ASPHostPortal.com :: Configure Costum Error in IIS 7.5 With ASP.NET

clock September 21, 2013 09:17 by author Ben

Now, I will explain how to configure custom error pages in IIS (Internet Information Service). For this example we will be using IIS 7.5 which shipped with Windows Server 2008 R2.

First Step, Open Internet Information Services (IIS) Manager.  Select your website. Note: This could also be set at the server level and applied to all sites on the server. DoubleClick on the “.NET Error Pages” icon.


The .NET Error Pages features view will be displayed.


Click the “Edit Feature Settings” link to enable this feature. The “Edit Error Page Settings” dialog box will appear.


How to determine the error code 404 explicitly..

First, On the .NET Error Pages Actions menu click the Add link.


The “Add Custom Error Page” dialog will appear. This is where we define individual error pages per status code. For our example we will add a custom page for the HTTP 404 Error.




Now that we have turned on the feature and added a custom page for the 404 status code we can verify it is working. Please reload your website.

As mentioned above this can also be managed from the site’s web.config file. Consider the following configuration section from our site’s web.config file.



Windows 2008 Hosting Tips :: Installing IIS 7.5 on Windows Server 2008/2008 R2

clock July 1, 2013 09:05 by author Mike

IIS (Internet Information Services) Version 7.5 – is a web server application and a set of feature extension modules created by Microsoft for use with Microsoft Windows. Released with Windows Server 2008 R2 and Windows 7. The installation procedure to install IIS 7.5 is slightly different depending on which operating system you are using, so you will need to make sure you follow the correct method below for your operating system.

Follow this steps to install:

  • Navigate to Start\Control Panel\Administrative Tools and open Server Manager.
  • In the tree menu on the left, select Roles.
  • In the main window, find the sub-section Roles Summary (it should be at the top) and click Add Roles.
  • On the pop-up window, read the security warnings and then select Next.
  • Select Web Server (IIS) from the list of check box options.
  • After reading the introduction to IIS, click Next to continue
  • From the check boxes, find the Application Development section and select CGI. This will allow us to install PHP later without any modifications.

 

  • Click Next to continue.
  • Click Install to begin the installation.
  • After installation has finished, click Close.

To check the installation, you can follow this steps:
- Navigate to Start\Control Panel\Administrative Tools and open Internet Information Services (IIS) Manager.

 

If it's installed properly you'll be introduced with the IIS Manager window, shown below.

That's it, IIS 7.5 is now installed and ready to be put into service.



IIS 7.5 Hosting :: Configuring Pinging to Avoid Terminating Processes

clock June 17, 2013 14:01 by author Ben

IIS monitors the worker processes health by sending a periodic request the worker processes. This pinging is to ensure that if the worker processes responding the incoming requests in timely manner. If the worker process does not respond in a timely manner, IIS terminates the process after a specific number of ping.  Now, consider you are debugging your web application by attaching w3wp.exe from Visual Studio.  During debugging, it might take a long to find out result of debugging and as an out come, execution is on hold as you are pausing around with some breakpoints or playing around the code.

In between your debugging, IIS sending a ping to check worker process health and found it’s not responding, as you are holding the execution around breakpoint or other operation with in visual studio. Resulting of that, IIS terminates the process and you will get error message “The web server process that was being debugged has been terminated by Internet Information Services” .

Now think about it,  you are middle of a debugging session and the worker process process terminates. This will stop your entire debugging. This is quite frustrating and irritating when you are in a middle of debugging and debugger terminates because of the worker process.

Here is the solution:

Open the application pool from IIS Manager and navigate to “Advanced Settings” from the context menu of selected application pool.

This will open “Advanced settings” dialog window. Move to “Process Model” section

By default, you will find,

Ping Enabled = True with Ping Maximum Response Time = 90s and Ping Period = 30s

If worker process responding with in the specified time frame, IIS will keep the worker process alive. But considering the debugging time, the maximum response time is very less.

What you can do over here is, increase the Ping Maximum Response Time  with some values which can ensure worker process will get a response in between health check.

Or, Disable the Pinging by Ping Enabled = False  . By this setting IIS will stop pining your worker process for health checkup.

Note :  This is recommended only for your development environment.  Don’t disable it on Test, staging or Production environments. Worker process health monitoring, terminating processes when there is no timely request are very crucial for application performance.



IIS 7.5 Hosting - ASPHostPortal :: GZIP compression in IIS 7.5 for JSON response

clock May 15, 2013 12:20 by author Ben

Recently we need to build some RESTful services that responded with JSON and to my surprise these responses are not compressed when I fired up Fiddler and check the Transformer tab.

After enabling Failed Request Tracing in IIS by going to IIS Manager > Web Site > Right Panel > Actions Configure > Failed Request Tracing.

On the same page with the Right Panel of "Actions", under the IIS area, click into Failed Request Tracing Rules.

From there, at the Right Panel, click "Add..." > Specify Content to Trace > All content(*) > Status code(s): type in "200" > Finish.

You should make sure no other request is hitting on the same server at the same time to minimize the logging file creation, which is based on request, if you only have one request when you turn this on, there should only be one fr000001.xml file created in %windir%\inetpub\logs\FailedReqLogFiles\W3SVC1, open that in Internat Explorer and click on Request Details > Search for Compression, expand the corresponding node > Mine says in the node dynamic compression > not success > no_matching_content_type.

So it seems that even though by default HTTP Compression is enabled in IIS 7.5, there are only 3 content types that IIS recognizes and will actually perform the compression.

You can check this in IIS Manager > YOUR_SERVER > Under Management section > Configuration Editor > Expand the system.webServer > httpCompression > dynamicTypes

When you have a RESTful service that serve JSON based response and you would like that to be gzip/compressed whenever client's request includes in the header "Accept-Encoding: gzip", you must update this list to include both mime types

application/json
application/json;
charset=utf-8


in the list, you can either start adding these 2 type in the editor itself or you can run a command line tool AppCmd.exe from %windir%\system32\inetsrv directory, the full command is

appcmd.exe set config -section:system.webServer/httpCompression /+"dynamicTypes.[mimeType='application/json; charset=utf-8',enabled='True']" /commit:apphost

Remember to apply your settings if you are using the GUI editor, I used the command line tool because this is the only one that will add the type along with the "Entry Path", adding through the GUI editor for some reason doesn't add any Entry Type, it still works but I just don't like missing anything.

Now, restart IIS and you can check again in Fiddler and Viola! Now it says GZIP Encoding. You can "Click here to transform" to see the data :)



About ASPHostPortal.com

We’re a company that works differently to most. Value is what we output and help our customers achieve, not how much money we put in the bank. It’s not because we are altruistic. It’s based on an even simpler principle. "Do good things, and good things will come to you".

Success for us is something that is continually experienced, not something that is reached. For us it is all about the experience – more than the journey. Life is a continual experience. We see the Internet as being an incredible amplifier to the experience of life for all of us. It can help humanity come together to explode in knowledge exploration and discussion. It is continual enlightenment of new ideas, experiences, and passions


Author Link


Corporate Address (Location)

ASPHostPortal
170 W 56th Street, Suite 121
New York, NY 10019
United States

Sign in