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 8.5 Hosting with ASPHostPortal.com :: How to Install IIS 8.5 on Windows Server 2012 R2

clock February 12, 2014 06:01 by author Ben

In this blog I will run the steps to install Internet Information Services (IIS Version 8.5) on Windows Server 2012 R2. IIS 8.5 will be released with the Windows Server 2012 R2 product. With IIS 8.5, the IIS team continued its focus on scalability and manageability improvements.

1.  Open Server Manager by clicking the Server Manager icon on the desktop, next to Start icon.



2.  In the Server Manager window, with the Dashboard selected, click the Manage menu, and then click Add Roles and Features - click Next.

3. Select Role-Based o feature-based installation and Next


4. Select a server from the server pool and Next.

5. On the Select server roles, select Web Server (IIS) role. Click Next.



6. On the Add features that are required for Web Server (IIS), select Include management tools (if application). Click Add Features then click Next.
7. On the Select role services, select all the components depending on your requirement. Click Next.

8. On the Confirm installation selections, check Restart the destination server automatically if required. Click Yes to confirm automatic restart. Click Install.
9. On the Installation progress screen, click Close once the installation is completed. It can be closed before installation is completed and it would not interrupt the installation.
10. To confirm if the installation is successful or not, open Internet Explorer and type http://localhost, hit Enter. Default IIS page will be displayed. It is a confirmation that IIS
is successfully installed.

US Affordable IIS 8.5 Hosting with ASPHostPortal.com :
"ASPHostPortal.com is proud to be one of the first ASP.NET Hosting providers to offer IIS 8.5 Hosting on our most improved Windows 2012 R2 hosting platform. It makes easy to use the most current version of websites tools like Visual Studio and WebMatrix. With our IIS 8.5 Hosting will increase your website security and reliability. We also allow Full Trust on our IIS 8.5 Hosting."



Free Windows Server 2012 Hosting - ASPHostPortal.com :: New Powershell v3 with Windows Server 2012

clock December 7, 2013 06:25 by author Ben

PowerShell v3.0 is the version included with Server 2012. A great place for PowerShell newbies to get started is with PowerShell's IntelliSense. This feature will help you learn and create the proper PowerShell. As you type in a PowerShell command, you'll see a list of possible syntaxes to go with the command.

 


For example, you may want to install a feature through PowerShell, but are unsure of the proper syntax or exact feature name. Features can be installed through PowerShell with the command instaW-windowsfeature-name. If you go into the Windows PowВ­erShell ISE (integrated scripting engine) and start typing Install . You'll see a dropВ­down menu of all the possible commands that can be used with Install (image 1).

Image 1 - PowerShell IIntelliSense

Image 1 - that you also have a list of modules to scroll through to find the available cmdlets in PowerShell. PowerShell in Server 2012 provides command-line management , and with IntelliSense, also teaches you how to use correct PowerShell syntax at the same time.

WHile there are numerous new capabilities in PowerShell, another significant new feaВ­ture that many of you will want to get acquainted with is Windows PowerShell  Web Access. This feature allows you to manage remote machines using PowerShell through a web browser.


To set up this feature, follow these steps:

1. From Server Manager 's dashboard, click "Add roles and features." Click Next and select "Role-based or feature-based installation." Click Next. Select the server for installation. Click Next again. In the "Select server roles" window, click Features from the left-side menu. Scroll through the features until you see "Windows PowВ­erShell (Installed)." Expand this feature, and Windows PowerShell Web Access  is listed.



2. Select Windows PowerShell Web Access and click Add Features. Click Next three times and then click Install.

3. To automatically configure Windows PowerShell Web Access to use default settings, run Install-PswaWebApplication as an administrator in PowerShell.
After installation, you will see IIS listed in the Server Manager dashboard. The next step in setting up PowerShell Web Access is to configure IIS. In this example, you'll set up PowerShell Web Access in an IIS subfolder:


a. From Server Manager, click Tools and then IIS Manager. Now you need to create an application pool, which is done by expanding the IIS server name, right-clicking on Application Pools, and then selecting Add Application Pools.

b. Name the PowerShell Web Access application pool and click OK.

 

 



c. Right-click the Sites Folder under Default Web Site in the left hand IIS Manager pane. Select Add Application.

d. Enter an alias for the application and browse to select the application pool created in PowerShell Web Access. Also enter the physical path to PowerShell Web Access, which is file:///c:windowswebpowershellwebaccesswwwroot"C:WindowsWebPowerShellWebAccesswwwroot Configure and check authentication by using the "Connect as" and "Test settings" buttons. Click OK.

You can remotely use PowerShell Web Access through a browser by entering the name of the computer PowerShell Web Access is installed on and the name of the PowerShell Web Access Application as a URL in a browser.

SO, for this example, the machine name is DC1 and the PowerShell Web Access Application name is PSWA. After entering the URL http://dc1/pswa > Http://DC1/PSWA , We get the logon screen shown.



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.



WCF Hosting Trial - ASPHostPortal.com :: Consuming AJAX-Enabled WCF Services from both Client and Server

clock October 24, 2013 11:38 by author Ben

This is a simple example of an Ajax-Enabled WCF Service (hosted in IIS) that can be consumed using both client-side and server-side code.

1. Add a WCF Service Application project to the solution called FooService

2. Delete everything in the service project’s web.config file.

 

a. Create a class file called FooServiceOne.cs
b. Replace the code with this:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.ServiceModel.Web;

namespace GooberFoo.FooServices
{

    [ServiceContract(Namespace = "GooberFoo.FooServices")]
    public interface IFooServiceOne
    {
        [OperationContract]
        double Add(double n1, double n2);
    }

    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class FooServiceOne : IFooServiceOne
    {
        public double Add(double n1, double n2)
        {
            return n1 + n2;
        }
    }
}

c. Create another file called FooServiceOne.svc and past the following code into the file.

<%@ServiceHost
         language="C#"
         Debug="true"
         Service="GooberFoo.FooServices.FooServiceOne"
         Factory="System.ServiceModel.Activation.WebScriptServiceHostFactory"
 %>

d. Save and Compile

3. Host in IIS

a. Make sure "Enable anonymous access" is checked.
b. Make sure "Integrated Windows authentication" is unchecked.
c. Test the service by navigating to http://*******:90/FooServiceOne.svc
d. The service will be displayed with the message "Metadata publishing for this service is currently disabled."

4. Access the service from the client-side code

a. Create an Empty ASP.NET Web Application in your solution.
b. Drag and drop an AJAX Extensions ScriptManager control into your web page.
c. In the ServiceReference Collection Editor, set the path to http://********:90/FooServiceOne.svc
d. Drag and Drop an ASP.NET button and Label control on the page.

 <asp:Button ID="Button1" runat="server" OnClientClick="return Button1_Click();" Text="Add 5 and 7" />
 <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>

e. Add client-side script. 

<script language="javascript" type="text/javascript">
     function onSuccess(result) {
       document.getElementById('<%=Label1.ClientID %>').innerHTML = result;
     }
     function Button1_Click() {
       var proxy = new GooberFoo.FooServices.IFooServiceOne();
       proxy.Add(parseFloat(5), parseFloat(7), onSuccess, null, null);
       return false;
     }
 </script>

f. Compile and test.

5. Modify the service project to allow server-side code to consume the service

Change the service project's web.config file to look like this.

<?xml version="1.0"?>
        <configuration>
          <system.serviceModel>

            <bindings>
              <basicHttpBinding>
                <binding name="basicHttpBinding" closeTimeout="00:01:00"
                    openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                    allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                    maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                    messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                    useDefaultWebProxy="true">
                  <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                      maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                  <security mode="None">
                    <transport clientCredentialType="None" proxyCredentialType="None"
                        realm="" />
                    <message clientCredentialType="UserName" algorithmSuite="Default" />
                  </security>
                </binding>
              </basicHttpBinding>
            </bindings>

            <behaviors>
              <serviceBehaviors>
                <behavior name="AspNetAjaxBehavior" >
                  <serviceMetadata httpGetEnabled="true" />
                </behavior>
              </serviceBehaviors>

              <endpointBehaviors>
                <behavior name="AspNetSOAPBehavior">
                </behavior>
              </endpointBehaviors>
            </behaviors>

            <services>
              <service name="GooberFoo.FooServices.FooServiceOne" behaviorConfiguration="AspNetAjaxBehavior" >
                <endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
                <endpoint address="soapreq" behaviorConfiguration="AspNetSOAPBehavior" bindingConfiguration="basicHttpBinding"
                          binding="basicHttpBinding" contract="GooberFoo.FooServices.IFooServiceOne" name="GooberFoo.FooServices.IFooServiceOne" />
              </service>
            </services>
          </system.serviceModel>
        </configuration>

6. Test the Service

a. In IE, open the URL http://*******:90/FooServiceOne.svc.
b. You will see the FooServiceOne Service page along with instructions to use svcutil.exe http://*******:90/FooServiceOne.svc?wsdl

7. Add the Web Reference to your asp.net web application

a. In your web application, "Add Service Reference".
b. Use http://GooberServer:90/FooServiceOne.svc?wsdl
c. Click Go.
d. Use FooServiceOneRef as the namespace.
e. Click OK.
f. View web application’s web.config file.

8. Use server-side C# code to consume the service in your web application

a. Add Button control to the page along with a button click event.

 <asp:Button ID="Button2" runat="server" Text="Add 10 and 13" onclick="Button2_Click" />

b. The button click event will look like this:

protected void Button2_Click(object sender, EventArgs e)
 {
   FooServiceOneRef.FooServiceOneClient mySvc = new FooServiceOneRef.FooServiceOneClient();
   Label1.Text = Convert.ToString(mySvc.Add(10, 13));
 }

c. Compile and test.



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.



Tip IIS 8.0 Hosting :: Enabling SSL on IIS 8.0 Using Self-Signed Certificates

clock June 10, 2013 12:27 by author Ben

SSL enables browsers to communicate with a web-server over a secure channel that prevents eavesdropping, tampering and message forgery.  You should always use SSL for login pages where users are entering usernames/passwords, as well as for all other sensitive pages on sites (for example: account pages that show financial or personal information). 

Configuring SSL on Windows with previous versions of IIS has been a pain.  Figuring out how to install and manage a certificate, and then associate it with a web-site, is something I bet most web developers don't know how to enable.

The good news is that IIS 8.0 makes it radically easier to configure and enable SSL.  IIS 8.0 also now has built-in support for creating "Self Signed Certificates" that enable you to easily create test/personal certificates that you can use to quickly SSL enable a site for development or test purposes. 

Using IIS 8.0 you can SSL enable an existing web site in under 30 seconds.  The below tutorial demonstrates how to-do this.

Step 1: Create a New Web Site

We'll start by creating a new web-site using the new IIS 8.0 admin tool.  This admin tool is a complete re-write of the previous IIS admin tool (and was written entirely in managed code using Windows Forms), and provides a more logical organization of web features.  It provides a GUI admin experience for all ASP.NET and IIS settings.

To create a new site on the box, right click on the "Web Sites" node in the left hand tree-view pane and choose the "Add Web Site" context menu option.  Enter the appropriate details to create a new web-site:

One nice feature of IIS on Windows Vista is that you can now have an unlimited number of sites on a box (previous versions of IIS on Windows Client only allowed 1 site).  The 10 simultaneous request limitation on Windows Client versions of IIS also no longer exists with IIS 8.0.

Once we've completed the above steps, we will now have a brand new site running on our IIS web-server.

Step 2: Create a new Self Signed Certificate
Before binding SSL rules to our new site, we need to first import and setup a security certificate to use with the SSL binding. 

Certificates are managed in IIS 8.0 by clicking the root machine node in the left-hand tree-view explorer, and then selecting the "Server Certificates" icon in the feature pane on the right:

This will then list all certificates registered on the machine, and allow you to optionally import and/or create new ones.

I could optionally go to a certificate authority like Verisign and purchase a certificate to import using this admin UI.  Alternatively, I can create a "self-signed certificate" which is a test certificate that I can use during the development and testing of my site.  To-do this, click the "Create Self-Signed Certificate" link on the right-hand side of the admin tool:

Enter a name to use for the certificate (for example: "test") and hit ok.  IIS8 will then automatically create a new self-signed crypto certificate for you and register it on the machine:

Step 3: Enable HTTPS Bindings for our New Site
To SSL enable the web-site we created earlier, select the web-site node in the left-hand tree-view, and the click the "Bindings" link in its "actions" pane on the right-hand side of the screen:

This will then bring up a dialog that lists all of the binding rules that direct traffic to this site (meaning the host-header/IP address/port combinations for the site):

To enable SSL for the site, we'll want to click the "Add" button. This will bring up an "add binding" dialog that we can use to add HTTPS protocol support.  We can select the self-signed certificate we created earlier from the SSL certificate dropdownlist in the dialog, and in doing so indicate that we want to use that certificate when encrypting content over SSL:

Click ok, and we now have SSL enabled for our site:

Step 4: Test out the Site
Add a "default.aspx" page to the site, and then try and hit it with the browser by typing https://localhost/default.aspx (note the usage of "https" instead of "http" to indicate that you want to connect over SSL).

If you are using IE8, you'll likely see this anti-phishing error message kick in

Don't panic if this happens - it is just IE being helpful by suggesting that a self-signed certificate on your local machine looks suspicious. Click the "Continue to this website" link to bypass this security warning and proceed to the site.  You'll find that your default.aspx page is now running protected via SSL:

You are all done. :-)

Appendix: A Few Last SSL Notes
A few last SSL related notes:
The IIS 8.0 admin tool has an "SSL Settings" node that you can select for each site, directory or file that allows you to control whether that particular resource (and by default its children) requires an SSL request in order to execute.  This is useful for pages like a login.aspx page, where you want to guarantee that users can only enter their credentials when they are posting via an encrypted channel. If you configure the login.aspx page to require SSL, IIS 8.0 will block browsers from accessing it unless they are doing so over SSL.

Within an ASP.NET page or handler, you can programmatically check whether the current request is using SSL by checking the Request.IsSecure property (it will return "true" if the incoming browser request is over SSL).

You can set the "requireSSL" attribute on the <forms> configuration section within web.config files to have ASP.NET's forms-authentication system ensure that forms-authentication cookies are only set and used on SSL enabled pages and URLs.  This avoids the risk of a hacker trying to intercept the authentication cookie on a non-SSL secured page, and then trying to use a "replay attack" from a different machine to impersonate a user.



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