ASP.NET 4.5 and ASP.NET Core 1 Hosting BLOG

Tutorial and Articles about ASP.NET 4.0 and the latest ASP.NET 4.5 Hosting

ASP.NET 4.5 Hosting - ASP.NET 4.5 Asynchronous pages

clock March 4, 2013 10:37 by author andy_yo

To make a page asynchronous in earlier versions of ASP.NET, the page has to implement the interface IHttpAsyncHandler and define concrete definitions to all the methods declared in the interface. This takes considerable amount of time and effort to make the page asynchronous.
In ASP.NET 4.5, we can turn the execution of any operation asynchronous by using async and await keywords. Any new page added to an ASP.NET application is considered synchronous by default. We can change this by setting value of Async property of the Page directive to true. Once this property is set, we can use async and await keywords in any method in the code behind file.

<span style="font-family: "Calibri","sans-serif"; font-size: 11.0pt; line-height: 115%; mso-ansi-language: EN-IN; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: "Times New Roman"; mso-bidi-language: AR-SA; mso-bidi-theme-font: minor-bidi; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;"><%@ Page Language="C#" AutoEventWireup="true" Async="true" CodeBehind="Default.aspx.cs" Inherits="Async.Default" %>
</span>

About ASPHostPortal.com

ASPHostPortal.com is Microsoft No #1 Recommended Windows and ASP.NET Spotlight Hosting Partner in United States. Microsoft presents this award to ASPHostPortal.com for ability to support the latest Microsoft and ASP.NET technology, such as: WebMatrix, WebDeploy, Visual Studio 2012, ASP.NET 4.5, ASP.NET MVC 4.0, Silverlight 5 and Visual Studio Lightswitch. Click here for more information

This is because, performing asynchronous operations at wrong time may lead to some dangerous conditions on the server. By setting the Async attribute of the page, we are telling the server that, the current page is a safe place to perform async operations. Following is a sample page load event handler that calls a WCF service asynchronously and binds data to a GridView:

protected async void Page_Load(object sender, EventArgs e)
{
    var client = new DataServiceClient();
    var gettingCities = await client.GetCitiesAsync();
    gvCities.DataSource = gettingCities;
    gvCities.DataBind()                                               
}

Following are the set of steps performed when ASP.NET detects the await keyword in the above event handler:

  • Continues executing other synchronous tasks of the life cycle event
  • Once the above step is finished, the underlying synchronization context fires up an event saying that an async operation is pending
  • ASP.NET waits asynchronously till the pending task is completed and then it continues executing the rest of the statements
  • With above step, the life cycle (page load in this case) event is over. The control goes ahead to the next life cycle event

There is another way to achieve this. It is shown in the following snippet:

protected void Page_Load(object sender, EventArgs e)
{
    RegisterAsyncTask(new PageAsyncTask(async () =>
    {
        var client = new DataServiceClient();
        var gettingCities = await client.GetCitiesAsync();
        gvCities.DataSource = gettingCities;
        gvCities.DataBind();
    }));
}

The advantage of performing async operation this way over what we did earlier is that, it registers an asynchronous handler with the page and now the execution is not dependent on the synchronization context. Execution of the statements in the PageAsyncTask passed in is not dependent on page the page life cycle event. So, ASP.NET will not wait asynchronously after executing rest of the logic in the life cycle event. It would rather continue execution with the next life cycle event handlers. Statements in the registered task are performed whenever the dependent operation is finished.

Note that, we used the async keyword with a lambda expression. It is legal in .NET 4.5, because lambda is meant to create a single cast delegate with an anonymous method. To make the method executable asynchronously, we can use async and await with lambda.

 



ASP.NET Hosting - How to add favicon to your ASP.NET page

clock February 8, 2013 11:09 by author andy_yo

A favicon is the little image displayed at the left edge of the address bar in most browsers, or on the tab. Adding a Favicon is a nice way to enhance your website and give it a finished look.

About ASPHostPortal.com

ASPHostPortal.com is Microsoft No #1 Recommended Windows and ASP.NET Spotlight Hosting Partner in United States. Microsoft presents this award to ASPHostPortal.com for ability to support the latest Microsoft and ASP.NET technology, such as: WebMatrix, WebDeploy, Visual Studio 2012, ASP.NET 4.5, ASP.NET MVC 4.0, Silverlight 5 and Visual Studio Lightswitch. Click here for more information


Firefox displaying favicon:

Google Chrome displaying favicon:

 

Interner Explorer displaying favicon:

Adding a favicon to your website is very easy. First you need to create a 16 by 16 pixel icon and name it favicon.ico. No other file format or size will do. Save your favicon to the root directory of your ASP.Net web application:


In some older browsers (e.g., Internet Explorer 5), that's all it takes. For the latest versions of Firefox, Internet Explorer and Chrome, however, you need to add two links to your favicon to the head in your HTML. If you are using a master page, the same two links would go in the head on the master page.:

                <head runat="server">
                <
title>My Website</title>
                <
link runat="server" rel="shortcut icon" href="favicon.ico" type="image/x-icon"/>
                <
link runat="server" rel="icon" href="favicon.ico" type="image/ico"/>
          </
head>


The reason you have two links to the same favicon is to make sure your favicon works with most browsers. Some, such as Firefox, will work with either link. Internet Explorer versions 6 and 7 are especially picky. If you use both links, however, one is bound to work in almost any browser.



ASP.NET 4.5 Hosting - Bundling/Minification and Embedded Resources in ASP.NET

clock February 6, 2013 10:41 by author andy_yo

If you want to share your application resources(like css, javascript, images, etc) between different projects then embedded resource is a great choice. Embedded resource is also good for component/control writers because it allows component/control writers to distribute all the application resources with just a single assembly. A lot of vendors are already using this approach. It will great for component/control writers if they can leverage the ASP.NET bundling and minification for improving the performance. So, in this article we will show you how to write a very basic component(helper) which will use the ASP.NET bundling and minification feature on embedded javascript/css files.

 

About ASPHostPortal.com

ASPHostPortal.com is Microsoft No #1 Recommended Windows and ASP.NET Spotlight Hosting Partner in United States. Microsoft presents this award to ASPHostPortal.com for ability to support the latest Microsoft and ASP.NET technology, such as: WebMatrix, WebDeploy, Visual Studio 2012, ASP.NET 4.5, ASP.NET MVC 4.0, Silverlight 5 and Visual Studio Lightswitch. Click here for more information

First of all create a new Class Library project and install the Microsoft.AspNet.Mvc, WebActivator and Microsoft ASP.NET Web Optimization Framework 1.1.0-alpha1(make sure to include the -Pre parameter in Package Manager Console) nuget packages. Next, add a reference of System.Web assembly. Then, create your control/component/helper. For demonstration purpose, We will use this sample helper:

01.          public static class HtmlHelpers
02.          {

03.                          public static MvcHtmlString NewTextBox(this HtmlHelper html, string name)

04.                          {
05.                                          var js = Scripts.Render("~/Test/Embedded/Js").ToString();
06.                                          var css = Scripts.Render("~/Test/Embedded/Css").ToString();

07.                                          var textbox = html.TextBox(name).ToString();

08.                                          return MvcHtmlString.Create(textbox + js + css);

09.                          }
10.          }

 

In this helper, I am just using a textbox with a style and script bundle. Style bundle include 2 css files and script bundle include 2 js files. So, just create 2 css files(NewTextBox1.css and NewTextBox2.css) and 2 javascript files(NewTextBox1.js and NewTextBox2.js) and then mark these files as embedded resource. Next, add a AppStart.cs file and add the following lines inside this file:

01.          [assembly: WebActivator.PostApplicationStartMethod(typeof(AppStart), "Start")]
02.          namespace Test

03.          {

04.                          public static class AppStart

05.                          {

06.                                          public static void Start()

07.                                          {

08.                                                          ConfigureRoutes();

09.                                                          ConfigureBundles();

10.                                          }

11.                                          private static void ConfigureBundles()

12.                                          {

13.                                                          BundleTable.VirtualPathProvider = new
                                                             EmbeddedVirtualPathProvider(HostingEnvironment.VirtualPathProvider);

14.                                                          BundleTable.Bundles.Add(new ScriptBundle("~/Test/Embedded/Js")

15.                                                          .Include("~/Test/Embedded/NewTextBox1.js")

16.                                                          .Include("~/Test/Embedded/NewTextBox2.js")

17.                                                          );

18.                                                          BundleTable.Bundles.Add(new StyleBundle("~/Test/Embedded/Css")

19.                                                          .Include("~/Test/Embedded/NewTextBox1.css")

20.                                                          .Include("~/Test/Embedded/NewTextBox2.css")

21.                                                          );

22.                                          }

23.                                          private static void ConfigureRoutes()

24.                                          {

25.                                                          RouteTable.Routes.Insert(0,

26.                                                          new Route("Test/Embedded/{file}.{extension}",

27.                                                          new RouteValueDictionary(new { }),

28.                                                          new RouteValueDictionary(new { extension = "css|js" }),

29.                                                          new EmbeddedResourceRouteHandler()

30.                                                          ));

31.                                          }

32.                          }

33.          }

 

The above class using WebActivator's PostApplicationStartMethod, which allows your assembly to run some code after the Application_Start method of global.asax. The Start method simply register a custom virtual path provider and two bundles which are used in our NewText helper class. But ASP.NET optimization framework will only emit a bundle url when debug="false" or when BundleTable.EnableOptimizations = true. Therefore, we also need to handle the normal javascript and css requests. For this case, the above method has also register a specific route for handling embedded resource requests using EmbeddedResourceRouteHandler route handler. Here is the definition of this handler:

01.          public class EmbeddedResourceRouteHandler : IRouteHandler
02.          {

03.                          IHttpHandler IRouteHandler.GetHttpHandler(RequestContext requestContext)

04.                          {

05.                                          return new EmbeddedResourceHttpHandler(requestContext.RouteData);

06.                          }

07.          }

08.          public class EmbeddedResourceHttpHandler : IHttpHandler

09.          {

10.                          private RouteData _routeData;

11.                          public EmbeddedResourceHttpHandler(RouteData routeData)

12.                          {

13.                                          _routeData = routeData;

14.                          }

15.                          public bool IsReusable

16.                          {

17.                                          get { return false; }

18.                          }

19.                          public void ProcessRequest(HttpContext context)

20.                          {

21.                                          var routeDataValues = _routeData.Values;

22.                                          var fileName = routeDataValues["file"].ToString();

23.                                          var fileExtension = routeDataValues["extension"].ToString();

24.                                          string nameSpace = typeof(EmbeddedResourceHttpHandler)

25.                                          .Assembly

26.                                          .GetName()

27.                                          .Name;// Mostly the default namespace and assembly name are same

28.                                          string manifestResourceName = string.Format("{0}.{1}.{2}", nameSpace, fileName, fileExtension);

29.                                          var stream =
                                             typeof(EmbeddedResourceHttpHandler).Assembly.GetManifestResourceStream(manifestResourceName);

30.                                          context.Response.Clear();

31.                                          context.Response.ContentType = "text/css";// default

32.                                          if (fileExtension == "js")

33.                                          context.Response.ContentType = "text/javascript";

34.                                          stream.CopyTo(context.Response.OutputStream);

35.                          }

36.          }

 

EmbeddedResourceRouteHandler returns EmbeddedResourceHttpHandler http handler which will be used to extract embedded resource file from the assembly and then write the file to the response body. Now, the only missing thing is EmbeddedVirtualPathProvider:

01.          public class EmbeddedVirtualPathProvider : VirtualPathProvider
02.          {

03.                          private VirtualPathProvider _previous;

04.                          public EmbeddedVirtualPathProvider(VirtualPathProvider previous)

05.                          {

06.                                          _previous = previous;

07.                          }

08.                          public override bool FileExists(string virtualPath)

09.                          {

10.                                          if (IsEmbeddedPath(virtualPath))

11.                                                          return true;

12.                                          else

13.                                                          return _previous.FileExists(virtualPath);

14.                          }

15.                          public override CacheDependency GetCacheDependency(string virtualPath, IEnumerable virtualPathDependencies, DateTime
                             utcStart)

16.                          {

17.                                          if (IsEmbeddedPath(virtualPath))

18.                                          {

19.                                                          return null;

20.                                          }

21.                                          else

22.                                          {

23.                                                          return _previous.GetCacheDependency(virtualPath, virtualPathDependencies, utcStart);

24.                                          }

25.                          }

26.                          public override VirtualDirectory GetDirectory(string virtualDir)

27.                          {

28.                                          return _previous.GetDirectory(virtualDir);

29.                          }

30.                          public override bool DirectoryExists(string virtualDir)

31.                          {

32.                                          return _previous.DirectoryExists(virtualDir);

33.                          }

34.                          public override VirtualFile GetFile(string virtualPath)

35.                          {

36.                                          if (IsEmbeddedPath(virtualPath))

37.                                          {

38.                                                          string fileNameWithExtension = virtualPath.Substring(virtualPath.LastIndexOf("/") + 1);

39.                                                          string nameSpace = typeof(EmbeddedResourceHttpHandler)

40.                                                          .Assembly

41.                                                          .GetName()

42.                                                          .Name;// Mostly the default namespace and assembly name are same

43.                                                          string manifestResourceName = string.Format("{0}.{1}", nameSpace,
                                                             fileNameWithExtension);

44.                                                          var stream =
                                                             typeof(EmbeddedVirtualPathProvider).Assembly
                                                             .GetManifestResourceStream(manifestResourceName);

45.                                                          return new EmbeddedVirtualFile(virtualPath, stream);

46.                                          }

47.                                          else

48.                                                          return _previous.GetFile(virtualPath);

49.                          }

50.                          private bool IsEmbeddedPath(string path)

51.                          {

52.                                          return path.Contains("~/Test/Embedded");

53.                          }

54.          }

55.

56.          public class EmbeddedVirtualFile : VirtualFile

57.          {

58.                          private Stream _stream;

59.                          public EmbeddedVirtualFile(string virtualPath, Stream stream)

60.                          : base(virtualPath)

61.                          {

62.                                          _stream = stream;

63.                          }

64.                          public override Stream Open()

65.                          {

66.                                          return _stream;

67.                          }

68.          }

EmbeddedVirtualPathProvider class is self explanatory. It simply maps a bundling url(used above) and return the embedded request as stream. Note, this class will be invoked by ASP.NET optimization framework during bundling and minifying process. Now, just build your component/control/helper assembly. Then, create a sample ASP.NET(MVC) application and then use this component/control/helper in your page. For example, like,

1.@using Test.Helpers
2.@Html.NewTextBox("New")

 



Windows ASP.NET Hosting - Boosting Web Application Performance with Bundling and Minification

clock February 1, 2013 10:34 by author andy_yo

The performance of your web application has a great impact on the end user experience. If your web application is slow, obviously users are going to be turned away from using it. There are many factors that contribute to the performance of a web site. A couple of important ones are - the number of requests sent from the browser to the server and the response size of each request. The newly added optimization features of ASP.NET 4.5 provide a neat way to bundle and minify JavaScript and CSS files thus taking care of the issues mentioned earlier. This article shows how these bundling and minification features of ASP.NET can be utilized in your web application.

About ASPHostPortal.com

ASPHostPortal.com is Microsoft No #1 Recommended Windows and ASP.NET Spotlight Hosting Partner in United States. Microsoft presents this award to ASPHostPortal.com for ability to support the latest Microsoft and ASP.NET technology, such as: WebMatrix, WebDeploy, Visual Studio 2012, ASP.NET 4.5, ASP.NET MVC 4.0, Silverlight 5 and Visual Studio Lightswitch. Click here for more information

What is Bundling and Minification

Consider an ASP.NET MVC web application that consists of a view named Index.aspx and makes use of the following JavaScript files:

  • jquery-1.6.2.js
  • jquery-ui-1.8.11.js
  • modernizr-2.0.6-development-only.js

By default these files are located in the Scripts folder and you refer them in your views as follows:

  1. <script src="../../Scripts/jquery-1.6.2.js"></script>
  2. <script src="../../Scripts/jquery-ui-1.8.11.js"></script>
  3. <script src="../../Scripts/modernizr-2.0.6-development-only.js"></script>

Now, when the view is loaded in the browser, the browser makes three independent requests to the respective files. If you observe the requests using Chrome Developer Tools you will see something like this:

Notice a couple of things:

  • The browser has sent three separate requests to respective .js files.
  • The total response size will be the sum of the file sizes of the individual files.

Also, notice the time taken to download these files.

The overall performance of the view can be improved if you bundle all three requests as a single request. This way instead of making three separate requests the browser will send a single request and still download the content of all three files. Performance will be further improved if you minimize the size of each file being downloaded by minification techniques such as removing white spaces and comments.

Default Bundling and Minification

Luckily, ASP.NET 4.5 provides inbuilt support for bundling and minification of files. The core functionality of bundling and minification is found in System.Web.Optimization namespace. If you create a new ASP.NET project you will find the following line of code in the Global.aspx file:

  1. protected void Application_Start()
  2. {
  3. ...
  4. BundleTable.Bundles.RegisterTemplateBundles();
  5. }

As you can see, the Application_Start event handler contains a call to the RegisterTemplateBundles() method that does the default bundling and minification for you. For default bundling and minification to work you need to specify the URLs of the JavaScript and CSS files a bit differently.

  1. <script src="../../Scripts/js"></script>

Notice the above <script> tag carefully. Instead of specifying a <script> tag per file there is only one <script> tag and the src attribute is of the form <script_folder_path>/js. This naming convention tells ASP.NET that all the *.js files from the Scripts folder are to be bundled together and minified. If you observe the request in Chrome Developer Tools you will find just a single entry for JavaScript files like this:

Notice the size of the downloaded content and compare it with the combined size of individual files.

For CSS files you would have used <css_folder_path>/css in the <link> tag.

  1. <link rel="stylesheet" type="text/css" href="../../Content/css" />

Though the syntax shown above works as expected, there is a small drawback. Let's say you refer JavaScript and CSS files in your views using the above syntax and your web application starts serving the requests. Sometime later you update some of these JavaScript and CSS files. Naturally, you expect the new script and styles to come into effect. However, the earlier files might have been cached by the browser or proxy server. Since the URL to the files is the same (src="../../Scripts/js" and href="../../Content/css") there is no way for the browser to detect whether the files have been changed or not. To rectify the problem it is advisable to use the following syntax :

  1. <script src="<%= BundleTable.Bundles.ResolveBundleUrl("~/Scripts/js") %>"></script>
  2. <script src="<%= BundleTable.Bundles.ResolveBundleUrl("~/Content/css") %>"></script>

The ResolveBundleUrl() method accepts the virtual path of the folder containing the script or CSS files. The ResolveBundleUrl() method not only generates a URL for src and href attributes but also appends a unique string token in the query string. This token is changed when a file changes, thus ensuring a unique URL for the changed files. The following figure shows how the string token is added in the query string:

Customizing Bundling and Minification

At times the default bundling mechanism may not meet your requirements. For example, you might have ten JavaScript files in a folder but depending on the usage pattern you may want to bundle them in two separate bundles of five files each rather than a single bundle. Also, you may want to bundle the files in a specific sequence based on their dependencies. Such a customization is possible through Bundle class. The following code added to the Application_Start event handler shows how the Bundle class can be used:

  1. protected void Application_Start()
  2. {
  3. ...
  4. var bundle = new Bundle("~/MyScripts");
  5. bundle.AddFile("~/Scripts/jquery-1.6.2.js");
  6. bundle.AddFile("~/Scripts/jquery-ui-1.8.11.js");
  7. bundle.AddFile("~/Scripts/modernizr-2.0.6-development-only.js");
  8. BundleTable.Bundles.Add(bundle);
  9. ...
  10. }

The above code creates a new bundle for virtual path ~/MyScripts. It then calls the AddFile() method to add specific script files. Finally, the newly created bundle is added to the Bundles collection. To refer the newly created bundle in views you will use the following syntax:

  1. <script
  2. src="<%= BundleTable.Bundles.ResolveBundleUrl("~/MyScripts")
  3. %>"></script>

In addition to creating a custom bundle as shown above you can also customize the overall bundling and minification process. To do so, you need to create a custom class that implements the IBundleTransform interface. You then need to implement the Process() method of the IBundleTransform interface and write a custom processing logic. The following code shows a simple implementation of the IBundleTransform interface that adds a copyright notice to the bundled content.

  1. public class MyBundleTransform:IBundleTransform
  2. {
  3. public void Process(BundleContext context, BundleResponse response)
  4. {
  5. StringBuilder sb = new StringBuilder();
  6. sb.AppendLine("// Copyright (C) 2012. All rights reserved.");
  7. sb.Append(response.Content);
  8. response.Content = sb.ToString();
  9. }
  10. }

The above code creates the  MyBundleTransform class, which implements the IBundleTransform interface. The Process() method receives two parameters viz. a BundleContext and BundleResponse. The Process() method then adds a copyright notice at the top of the bundled content and then reassigns the Content property. You can also get ahold of the individual files of a bundle using the response.Files property.

To use the MyBundleTransform class you modify the Application_Start event handler as follows:

  1. protected void Application_Start()
  2. {
  3. ...
  4. var bundle = new Bundle("~/MyScripts", new MyBundleTransform()); bundle.AddFile("~/Scripts/jquery-1.6.2.js");
  5. bundle.AddFile("~/Scripts/jquery-ui-1.8.11.js");
  6. bundle.AddFile("~/Scripts/modernizr-2.0.6-development-only.js");
  7. BundleTable.Bundles.Add(bundle);
  8. ...
  9. }

As you can see a new bundle has been created as before but this time an instance of the MyBundleTransform class is passed as the second parameter of the constructor. If you observe the resultant script in the Chrome Developer Tools, you will find the copyright line added at the top:

Summary

The newly added bundling and minification features of ASP.NET 4.5 make it easy to bundle your JavaScript and CSS files thus boosting the overall performance of your web applications. In order to avail the bundling and minification features you need to specify URLs to script and CSS files in a certain way. Following this naming convention automatically bundles all of the JavaScript and CSS files from a folder and serves them as a single request. You can also customize the bundling process using the Bundle class and IBundleTransform interface.



ASP.NET 4.5 Hosting - ASP.NET Web Pages - Adding Razor Code

clock January 16, 2013 06:18 by author andy_yo

In this article we will learn how to use Razor markup with C# and Visual Basic code


What is Razor?

  • Razor is a markup syntax for adding server-based code to web pages
  • Razor has the power of traditional ASP.NET markup, but is easier to learn, and easier to use
  • Razor is a server side markup syntax much like ASP and PHP
  • Razor supports C# and Visual Basic programming languages

Adding Razor Code

<!DOCTYPE html>

<html lang="en">
<head>
<meta charset="utf-8" />
<title>Web Pages Demo</title>
</head>
<body>
<h1>Hello Web Pages</h1>
</body>
</html>

Now add some Razor code to the example:

Example

<!DOCTYPE html>

<html lang="en">
<head>
<meta charset="utf-8" />
<title>Web Pages Demo</title>
</head>
<body>
<h1>Hello Web Pages</h1>
<p>The time is @DateTime.Now</p>
</body>
</html>

The page contains ordinary HTML markup, with one addition: the @ marked Razor code.

The Razor code does all the work of determining the current time on the server and display it. (You can specify formatting options, or just display the default)


Main Razor Syntax Rules for C#

  • Razor code blocks are enclosed in @{ ... }
  • Inline expressions (variables and functions) start with @
  • Code statements end with semicolon
  • Variables are declared with the var keyword
  • Strings are enclosed with quotation marks
  • C# code is case sensitive
  • C# files have the extension .cshtml

C# Example

<!-- Single statement block -->
@{ var myMessage = "Hello World"; }

<!-- Inline expression or variable -->
<p>The value of myMessage is: @myMessage</p>

<!-- Multi-statement block -->
@{
var greeting = "Welcome to our site!";
var weekDay = DateTime.Now.DayOfWeek;
var greetingMessage = greeting + " Today is: " + weekDay;
}
<p>The greeting is: @greetingMessage</p>


Main Razor Syntax Rules for VB

  • Razor code blocks are enclosed in @Code ... End Code
  • Inline expressions (variables and functions) start with @
  • Variables are declared with the Dim keyword
  • Strings are enclosed with quotation marks
  • VB code is not case sensitive
  • VB files have the extension .vbhtml

Example

<!-- Single statement block  -->
@Code dim myMessage = "Hello World" End Code

<!-- Inline expression or variable -->
<p>The value of myMessage is: @myMessage</p>

<!-- Multi-statement block -->
@Code
dim greeting = "Welcome to our site!"
dim weekDay = DateTime.Now.DayOfWeek
dim greetingMessage = greeting & " Today is: " & weekDay
End Code

<p>The greeting is: @greetingMessage</p>

About ASPHostPortal.com

ASPHostPortal.com is Microsoft No #1 Recommended Windows and ASP.NET Spotlight Hosting Partner in United States. Microsoft presents this award to ASPHostPortal.com for ability to support the latest Microsoft and ASP.NET technology, such as: WebMatrix, WebDeploy, Visual Studio 2012, ASP.NET 4.5, ASP.NET MVC 4.0, Silverlight 5 and Visual Studio Lightswitch. Click here for more information



ASP.NET Hosting - ASPHostPortal :: Difference between appSettings and Connection Strings in ASP.NET web.config

clock October 22, 2012 08:59 by author Jervis

Now I will explain differences between appsettings and connection strings in web.config using asp.net.

In web.config file we can store the connection strings in two ways those are
appSettings and connectionStrings

AppSettings in web.config

The AppSettings section in web.config is used to store connection strings, server names, file paths, and other miscellaneous settings needed by an application.


Connection String in web.config

The connection string in web.config is a collection of database connection strings only.

Actually in previous versions of ASP.NET all connection string values are storing in appsettings only. In ASP.NET 2.0 + version new features has introduced such as Session, Membership, Personalization, and Role Manager these will depend on connection strings and stored in the connectionStrings element only.

Difference

The main difference is in appsettings section we can store any data string values including database connection strings also but in connectionStrings section only database connection strings can store those are our application connection strings and new features (Membership, Personalization and Role Manager) connection strings only.

Instead of this there is no much difference between appsettings and connectionStrings.

Reasons why you must trust ASPHostPortal.com

Every provider will tell you how they treat their support, uptime, expertise, guarantees, etc., are. Take a close look. What they’re really offering you is nothing close to what ASPHostPortal does. You will be treated with respect and provided the courtesy and service you would expect from a world-class web hosting business.


You’ll have highly trained, skilled professional technical support people ready, willing, and wanting to help you 24 hours a day. Your web hosting account servers are monitored from three monitoring points, with two alert points, every minute, 24 hours a day, 7 days a week, 365 days a year. The followings are the list of other added- benefits you can find when hosting with us:

- DELL Hardware
Dell hardware is engineered to keep critical enterprise applications running around the clock with clustered solutions fully tested and certified by Dell and other leading operating system and application providers.
- Recovery Systems
Recovery becomes easy and seamless with our fully managed backup services. We monitor your server to ensure your data is properly backed up and recoverable so when the time comes, you can easily repair or recover your data.

- Control Panel
We provide one of the most comprehensive customer control panels available. Providing maximum control and ease of use, our Control Panel serves as the central management point for your ASPHostPortal account. You’ll use a flexible, powerful hosting control panel that will give you direct control over your web hosting account. Our control panel and systems configuration is fully automated and this means your settings are configured automatically and instantly.

- Excellent Expertise in Technology
The reason we can provide you with a great amount of power, flexibility, and simplicity at such a discounted price is due to incredible efficiencies within our business. We have not just been providing hosting for many clients for years, we have also been researching, developing, and innovating every aspect of our operations, systems, procedures, strategy, management, and teams. Our operations are based on a continual improvement program where we review thousands of systems, operational and management metrics in real-time, to fine-tune every aspect of our operation and activities. We continually train and retrain all people in our teams. We provide all people in our teams with the time, space, and inspiration to research, understand, and explore the Internet in search of greater knowledge. We do this while providing you with the best hosting services for the lowest possible price.

- Data Center

ASPHostPortal modular Tier-3 data center was specifically designed to be a world-class web hosting facility totally dedicated to uncompromised performance and security
- Monitoring Services
From the moment your server is connected to our network it is monitored for connectivity, disk, memory and CPU utilization – as well as hardware failures. Our engineers are alerted to potential issues before they become critical.

- Network
ASPHostPortal has architected its network like no other hosting company. Every facet of our network infrastructure scales to gigabit speeds with no single point of failure.

- Security
Network security and the security of your server are ASPHostPortal’s top priorities. Our security team is constantly monitoring the entire network for unusual or suspicious behavior so that when it is detected we can address the issue before our network or your server is affected.

- Support Services
Engineers staff our data center 24 hours a day, 7 days a week, 365 days a year to manage the network infrastructure and oversee top-of-the-line servers that host our clients’ critical sites and services.

 



ASP.NET Hosting - ASPHostPortal :: How to Speed up Your Development Time

clock October 9, 2012 08:41 by author Jervis

In this article we will learn that how you can speed up your development time if you have many projects in your solution. It is very simple.

Introduction

Suppose we have many projects in our solution and we want to build only one project at a time so that our development time will be minimised. You all will think that it can be done simply by making one of your project as the start project. But my friends you cannot do it by that. This article is based on to show "How to speed up build time".


Procedure

Suppose you have two Projects in our Solution Explorer.



First we will configure Visual Studio to set one of the two project as "Start Project" as the Current Selection in the "Solution Explorer" window using the properties of one of your projects.




Now if you will build it then both the project will be builded like....




Here in the above picture you can see that both of your project is going to build. Now you can imagine the time it will take if you have hundreds of project in your one solution.


In your Visual Studio just click on "Tools" then "Options". In that click on "Projects and Solutions" and then click on "Build and Run".Like the picture given below....




You just have to check the checkBox "Only build startup projects and dependencies on Run." Now if you will return to your application and then start the startup project you will get like this




Hope this helps

 

 



ASP.NET Hosting - ASPHostPortal :: How to Fix - Operation is not valid due to the current state of the object

clock September 27, 2012 07:59 by author Jervis

ASP.NET requests that have lots of form keys, files, or JSON payload receive an error response from the server. The Application log on the server has a Warning entry with a Source that is a specific version of ASP.NET, and an Event ID of 1309. The event log contains one of the following messages:

Message 1:


Application information:

     Application domain: /LM/W3SVC/1/ROOT/<App Domain>
     Trust level: Medium
     Application Virtual Path: <VDIR Path>
     Application Path: <App Path>
     Machine name: <Machine Name>
Process information:
     Process ID: 0001
     Process name: w3wp.exe
     Account name: IIS APPPOOL\DefaultAppPool
Exception information:
     Exception type: HttpException
     Exception message: The URL-encoded form data is not valid.
     at System.Web.HttpRequest.FillInFormCollection()
     at System.Web.HttpRequest.get_Form()
     at System.Web.HttpRequest.get_HasForm()
     at System.Web.UI.Page.GetCollectionBasedOnMethod(Boolean dontReturnNull)
     at System.Web.UI.Page.DeterminePostBackMode()
     at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

Message 2:

Application information:

      Application domain: /LM/W3SVC/1/ROOT/<App Domain>
      Trust level: Medium
      Application Virtual Path: <VDIR Path>
      Application Path: <App Path>
      Machine name: <Machine Name>
Process information:
      Process ID: 0001
      Process name: w3wp.exe
      Account name: IIS APPPOOL\DefaultAppPool
Exception information:
      Exception type: InvalidOperationException
      Exception message: Operation is not valid due to the current state of the object.
      at System.Web.HttpRequest.FillInFilesCollection()
      at System.Web.HttpRequest.get_Files()
      at FileUpload.Page_Load(Object sender, EventArgs e)
      at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
      at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
      at System.Web.UI.Control.OnLoad(EventArgs e)
      at System.Web.UI.Control.LoadRecursive()
      at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint

to resolve this problem, you should change your web.config

<configuration>
  <appSettings>
    <add key="aspnet:MaxHttpCollectionKeys" value="5000" />
  </appSettings>
</configuration>

Reasons why you must trust ASPHostPortal.com

Every provider will tell you how they treat their support, uptime, expertise, guarantees, etc., are. Take a close look. What they’re really offering you is nothing close to what ASPHostPortal does. You will be treated with respect and provided the courtesy and service you would expect from a world-class web hosting business.

You’ll have highly trained, skilled professional technical support people ready, willing, and wanting to help you 24 hours a day. Your web hosting account servers are monitored from three monitoring points, with two alert points, every minute, 24 hours a day, 7 days a week, 365 days a year. The followings are the list of other added- benefits you can find when hosting with us:


-
DELL Hardware
Dell hardware is engineered to keep critical enterprise applications running around the clock with clustered solutions fully tested and certified by Dell and other leading operating system and application providers.
- Recovery Systems
Recovery becomes easy and seamless with our fully managed backup services. We monitor your server to ensure your data is properly backed up and recoverable so when the time comes, you can easily repair or recover your data.

- Control Panel
We provide one of the most comprehensive customer control panels available. Providing maximum control and ease of use, our Control Panel serves as the central management point for your ASPHostPortal account. You’ll use a flexible, powerful hosting control panel that will give you direct control over your web hosting account. Our control panel and systems configuration is fully automated and this means your settings are configured automatically and instantly.

- Excellent Expertise in Technology
The reason we can provide you with a great amount of power, flexibility, and simplicity at such a discounted price is due to incredible efficiencies within our business. We have not just been providing hosting for many clients for years, we have also been researching, developing, and innovating every aspect of our operations, systems, procedures, strategy, management, and teams. Our operations are based on a continual improvement program where we review thousands of systems, operational and management metrics in real-time, to fine-tune every aspect of our operation and activities. We continually train and retrain all people in our teams. We provide all people in our teams with the time, space, and inspiration to research, understand, and explore the Internet in search of greater knowledge. We do this while providing you with the best hosting services for the lowest possible price.

- Data Center

ASPHostPortal modular Tier-3 data center was specifically designed to be a world-class web hosting facility totally dedicated to uncompromised performance and security
- Monitoring Services
From the moment your server is connected to our network it is monitored for connectivity, disk, memory and CPU utilization – as well as hardware failures. Our engineers are alerted to potential issues before they become critical.

- Network
ASPHostPortal has architected its network like no other hosting company. Every facet of our network infrastructure scales to gigabit speeds with no single point of failure.

- Security
Network security and the security of your server are ASPHostPortal’s top priorities. Our security team is constantly monitoring the entire network for unusual or suspicious behavior so that when it is detected we can address the issue before our network or your server is affected.

- Support Services
Engineers staff our data center 24 hours a day, 7 days a week, 365 days a year to manage the network infrastructure and oversee top-of-the-line servers that host our clients’ critical sites and services.

 



Cheap ASP.NET 4.5 Hosting

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

Tag cloud

Sign in