All About ASP.NET and ASP.NET Core 2 Hosting BLOG

Tutorial and Articles about ASP.NET and the latest ASP.NET Core

ASP.NET Hosting Full Trust Mode

clock April 8, 2014 09:03 by author Diego

What’s ASP.NET shared hosting trust level?

You need to check many aspects before choosing a .Net hosting provider, those aspects should include .Net MVC framework, SQL Server, disk space, monthly bandwidth, hosting prices, but there’s one thing you may ignore really – “IIS Security Trust Level”.

If you’re not familiar with what’s shared hosting trust level, here I’d like to bring you a short introduction. The trust level is real important that could affect with your site secure and performance, and a full trust level means higher risk for hackers sneak into server to make destroy. Most of small .Net hosts only can give medium trust level on their servers. If your applications need to be run a full trust mode, then you’ve to look for a web host which can give full permission to you.

<trustLevel name="High" policyFile="web_hightrust.config"/>
<trustLevel name="Medium" policyFile="web_mediumtrust.config"/>
<trustLevel name="Low" policyFile="web_lowtrust.config"/>
<trustLevel name="Minimal" policyFile="web_minimaltrust.config"/>

You can see there are 4 trust levels for web hosts to pre-set by default – Minimal trust, Low trust, Medium trust and High / Full trust. High trust means higher risk for hackers to sneak into server, most of Windows hosting companies doesn’t allow their customers to run full trust level by default.
- Full Trust allows the users to do everything of application pool on one Windows web server. Some of applications cannot work properly under a medium trust web server, full trust means more flexible and you’re also able to change to medium trust once your application don’t need full trust.
- High Trust, websites are limited to call unmanaged code, e.g. Win32 APIs, COM interop.
- Medium Trust level websites are limited to access the file system and not so flexible as full trust level web server.
- Low Trust & Minimal Trust level are 2 options to restrict the users heavily, it won’t allow users to connect to server actively. At present, there’s no Windows hosts offering such shared hosting plan yet.

With more and more people and companies developing websites by Microsoft .NET technology, ASP.NET shared web hosting comes to be the major solution provided by many web hosting companies. Most of people choose an ASP.NET web host considering about .NET framework version, ASP.NET MVC support, SQL Server database, disk space or bandwidth but they usually ignore the most important feature “IIS security level”. That determines whether the ASP.NET websites can run successfully on the shared web host. In result to, if you developing an ASP.NET website that works well in the local development environment and attempt to run it in the ASP.NET shared web host, you may get the following exception.

System.Security.SecurityException: That assembly does not allow partially trusted callers.

This is caused by the security level of the ASP.NET shared web host that your application is forced to run with the limited permission, by locking down the access to server file system, preventing the background threads, or interacting with COM interfaces, etc.
Full Trust and Medium Trust are two widely used levels in ASP.NET shared web hosting. The full trust provides best flexibility but it has potential security issues to the shared server, especially when the web hosting provider doesn't have rich experience on setting up Windows permission and IIS. Compared to Full Trust, you have to review the website carefully before you go with a web host only supports Medium Trust Level. You can refer to the following checkpoints for the review.
-The website shall not call unmanaged APIs.

-The website shall not access to file system, system registry, event logs and anything else related to the system.
-The website shall not generate code for execution dynamically using Code DOM.

-The website shall not use XslTransform to transform something from XML using XSLT.

-The website has to be signed with a Strong Name.

Check with the web page from Microsoft about which namespaces and classes are not supported in Medium Trust environment.
And here is quick way to confirm the compatibility of websites to Medium Trust Level, in the local environment.

1. Add partially trusted callers attribute into AssemblyInfo.cs file of the website project, as following code snippet,
[assembly: AllowPartiallyTrustedCallers]

2.Add the following line into the web.config,
<trust level="Medium" />

Medium Trust or Full Trust level? UP to Your choice:
If your website can be working fine under medium trust level, I suggest you don’t need a full trust hosting, most of popular .Net applications should be working fine under a medium trust level server, only when your application has to be run under a full trust level enviroment, then you can find an ASP.NET full trust hosting company.

FREE Trial 7 Days ASP.NET Hosting | No Setup Fees! | 24/7 Support | 99.9% Uptime

clock March 14, 2014 11:33 by author Diego, no#1 Microsoft RECOMMENDED hosting partner, 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 Company offers secure and reliable web hosting for individuals and businesses owners. We are offering shared and reseller hosting and domain names services. Our best cheap hosting packages come with friendly and fast support and with no setup or other hidden fees. All the servers have the latest stable version of Plesk Panel. We listened our customers and now we offer SEVEN Days FREE on all  shared payments. is proud to offer a FREE Trial ASP.NET 4 Hosting. We believes in try it before buy it. We are completely confident in our ASP.NET 4 hosting quality and customer service. Anyone is welcome to come and try us before they decide whether or not they want to buy. If the service does not meet your expectations simply cancel before the end of the free trial period.

Tired of SPAM? So are we! All shared & reseller hosting accounts come with FREE SpamExperts incoming email filtering for 1 domain.

FREE ASP.NET 4 Hosting Complete Features:

  • Hosted Domains UNLIMITED
  • Disk Space 5 GB
  • Bandwith 60 GB
  • Total SQL database 2
  • MSSQL/database 200 mb
  • Total MySQL database 3
  • MySQL/database 200 mb
  • UNLIMITED Email Account
  • Email Space 200 MB
  • US, European and Asia Data Center

More Info | Order Now!

Main Windows ASP.NET Hosting Features:

  • Support ASP.NET 1.0/2.0/3.5/4.0 Hosting and ASP.NET 4.5 Hosting
  • Support ASP.NET MVC 3 Hosting and ASP.NET MVC 4 Hosting
  • Support WCF RIA, Silverlight 4 and Silverlight 5 Hosting
  • Support Visual Studio 2010 Hosting and Visual Studio 2012 Hosting
  • Support SQL 2008, SQL 2008 R2, and SQL 2012 Hosting
  • Support Visual Studio LightSwitch Hosting
  • Support Web Deploy Hosting
  • FREE 100 Installation, such as Wordpress, Joomla, Umbraco, DotNetNuke, Orchard, Drupal, etc

Contact Us
If you have any questions, you can reach us via email or send us a tweet @asphostportal

About Us is a hosting company that best support in Windows and ASP.NET-based hosting. Services include shared hosting, reseller hosting, and sharepoint hosting, with specialty in ASP.NET, SQL Server, and architecting highly scalable solutions. As a leading small to mid-sized business web hosting provider, ASPHostPortal strive to offer the most technologically advanced hosting solutions available to all customers across the world. Security, reliability, and performance are at the core of hosting operations to ensure each site and/or application hosted is highly secured and performs at optimum level.

ASP.NET MVC 5 Hosting - with :: How to Rendering ASP.NET MVC 1.0, 2.0 RC, 3 and 4 Razor Views to String

clock March 14, 2014 07:44 by author Diego

The ASP.NET MVC Razor implementation is closely tied to ASP.NET and MVC and the View template (WebViewPage class) includes a few MVC-specific features as well as back references to the controller. In other words MVC Razor is designed with MVC in mind. With Razor, you can create a custom Razor Engine that can be used in any .NET environment. Razor is the best view engine available for MVC as its much cleaner and easy to write and read. This view engine is compatible with unit testing frameworks. In this article, I will demonstrate how you can render ASP.NET MVC Razor Views in ASP.Net MVC 1.0, 2.0 RC, 3 and 4 .
Basically, all you do is create a fake HttpContext for the view to render itself.  This is an extensions method of the HtmlHelper that processes a partial view through the default MVC view engine and then renders it to the response stream.

Thisworks on ASP.NET MVC 1.0 (changing Headers on the original HttpResponse doesn't throwthe "Server cannot set content type after HTTP headers have been sent"exception).
/// <summary>Renders a view to string.</summary>
public static string RenderViewToString(this Controller controller, string viewName, object viewData) {

Create memory writer.

var sb = new StringBuilder();
var memWriter = new StringWriter(sb);

Create fake http context to render the view.

    var fakeResponse = new HttpResponse(memWriter);
    var fakeContext = new HttpContext(HttpContext.Current.Request, fakeResponse);
    var fakeControllerContext = new ControllerContext(
        new HttpContextWrapper(fakeContext),
    var oldContext = HttpContext.Current;
    HttpContext.Current = fakeContext;
  Use HtmlHelper to render partial view to fake context.
    var html = new HtmlHelper(new ViewContext(fakeControllerContext,
        new FakeView(), new ViewDataDictionary(), new TempDataDictionary()),
        new ViewPage());
    html.RenderPartial(viewName, viewData);
Restore context.
    HttpContext.Current = oldContext;  
    //Flush memory and return output
    return sb.ToString();}
Fake IView implementation used to instantiate an HtmlHelper.
public class FakeView : IView {
    #region IView Members
    public void Render(ViewContext viewContext, System.IO.TextWriter writer) {
        throw new NotImplementedException();
    }    #endregion

In ASP.NET MVC 2.0 RC, the code changes a bit because we have to pass in the StringWriter used to write the view into the ViewContext:
Use HtmlHelper to render partial view to fake context.

var html = new HtmlHelper(
    new ViewContext(fakeControllerContext, new FakeView(),
        new ViewDataDictionary(), new TempDataDictionary(), memWriter),
    new ViewPage());
html.RenderPartial(viewName, viewData);

In MVC 3 you can used this code :
public static string RazorRender(Controller context, string DefaultAction)
string Cache = string.Empty;
System.Text.StringBuilder sb = new System.Text.StringBuilder();
System.IO.TextWriter tw = new System.IO.StringWriter(sb);
RazorView view_ = new RazorView(context.ControllerContext, DefaultAction, null, false, null);
view_.Render(new ViewContext(context.ControllerContext, view_, new ViewDataDictionary(), new TempDataDictionary(), tw), tw);
Cache = sb.ToString();
return Cache;
public static string RenderRazorViewToString(string viewName, object model)
ViewData.Model = model;
using (var sw = new StringWriter())
var viewResult = ViewEngines.Engines.FindPartialView(ControllerContext, viewName);
var viewContext = new ViewContext(ControllerContext, viewResult.View, ViewData, TempData, sw);
viewResult.View.Render(viewContext, sw);
return sw.GetStringBuilder().ToString();
public static class HtmlHelperExtensions
public static string RenderPartialToString(ControllerContext context, string partialViewName, ViewDataDictionary viewData, TempDataDictionary tempData)
ViewEngineResult result = ViewEngines.Engines.FindPartialView(context, partialViewName);
if (result.View != null)
StringBuilder sb = new StringBuilder();
using (StringWriter sw = new StringWriter(sb))
using (HtmlTextWriter output = new HtmlTextWriter(sw))
ViewContext viewContext = new ViewContext(context, result.View, viewData, tempData, output);
result.View.Render(viewContext, output);
return sb.ToString();

return String.Empty;

This code worked in MVC 4 :
public string RenderRazorViewToString(string viewName, object model) {
    ViewData.Model = model;
    using (var sw = new StringWriter()) {
        var viewResult = ViewEngines.Engines.FindPartialView(ControllerContext, viewName);
        var viewContext = new ViewContext(ControllerContext, viewResult.View, ViewData, TempData, sw);
        viewResult.View.Render(viewContext, sw);
        viewResult.ViewEngine.ReleaseView(ControllerContext, viewResult.View);
        return sw.GetStringBuilder().ToString();

I hope you will enjoy this Article, and I hope you will refer this article for your need. Stay tuned and stay connected for more technical updates with ASPHostPortal

ASP.NET MVC 5 Hosting - with :: What are Differences ViewBag, ViewData and TempData in Asp.Net MVC 5 ?

clock March 12, 2014 05:49 by author Diego

In Asp.Net MVC 5 (Model-View-Controller) there are three options ViewBag, ViewData, and TempData to pass small amount of data from controller to view. In this article i am going to explain what is ViewBag, ViewData and TempData and their use in Asp.Net MVC 5.

A. ViewData & ViewBag objects.
is a dictionary object that you put data into, which then becomes available to the view.It is an in-built dictionary object that is derived from ViewDataDictionary class that can be accessed and set with string type key values. It is a used to pass data from Controller to View. ViewData's value become null if redirection occur because its life lies only during current request.

Key points to remember about ViewData.

  • ViewData is a dictionary of objects that is derived from ViewDataDictionary class and accessible using strings as keys.
  • ViewData requires typecasting for complex data type and it is recommended to check for null values to avoid error.
  • ViewData is used to pass small amount of data from controller to view, so it helps to maintain data when moving from controller to view.
  • ViewData has short life i.e.  Its value becomes null when redirection occurs because its life lies only during current request. This is because the aim of ViewData is to provide a way to transfer/pass data from controllers and views.
  • ViewData is faster than ViewBag.

ViewData Example.
In View:


ViewBag is dynamic object, meaning we can add properties to it in the controller, and read them later in the view. Its value becomes null when redirection occurs because its life lies only during current request. This is because the aim of ViewBag is to provide a way to transfer/pass data from controllers and views.

ViewBag Example:
In View:


Similarities between ViewBag & ViewData :
Both the ViewData and ViewBag objects are great for accessing extra data (i.e., outside the data model), between the controller and view. Since views already expect a specific object as their model, this type of data access to extra data, MVC implements it as a property of both views and controllers, making usage and access to these objects easy. Helps to maintain data when you move from controller to view. Used to pass data from controller to corresponding view. Short life means value becomes null when redirection occurs. This is because their goal is to provide a way to communicate between controllers and views. It’s a communication mechanism within the server call.

Difference between ViewBag & ViewData:

  • ViewData is a dictionary of objects that is derived from ViewDataDictionary class and accessible using strings as keys.
  • ViewBag is a dynamic property that takes advantage of the new dynamic features in C# 4.0.
  • ViewData requires typecasting for complex data type and check for null values to avoid error.
  • ViewBag doesn’t require typecasting for complex data type.

B. TempData Object.The problem with the ViewData and ViewBag for transferring data from controller to view is that the data is only alive for current request. The data is lost if a redirection takes place i.e. if one Action redirects to another action. But when we need to persist the data between actions/redirection then MVC offers another dictionary object called TempData for that purpose. It is derived from TempDataDictionary and created on top of session. It will live till the redirected view is fully loaded. “TempData”  Helps to maintain data when you move from one controller to other controller or from one action to other action.The benefit is that if you have a chain of multiple redirections it won’t cause TempData to be emptied the values will still be there until you actually use them, then they clear up after themselves automatically.

When to use TempData in ASP.NET MVC ?
Example condition :

I came across this problem where I had a basic list of items and for each if these items I wanted to add a delete action on my controller. I wanted to add some error checking around the delete action so if someone attempted to modify the URL and enter a incorrect parameter into my controller, I wanted to redirect back to the previous controller and notify the user of this mistake. Take this example. I have a Product Controller and the Index Action and View lists all of the products. I have a delete action on the Product Controller which checks if the productId parameter is valid and then removes the product and redirects to the Index action using the RedirectToAction method.

The solution :
When validating the productId, if its NOT valid simply add a new key/value to the TempData object and call the RedirectToAction method. TempData stores data for short periods of time for the current and next HTTP request. In your index view, you can check to see if your key/value pair exists and display a error message. If you refresh the page, you will notice the data from the TempData will be gone. Remember to use RedirectToAction where possible as this is more friendly with Unit Testing rather than using the HttpResponse redirect method.

I hope you have got what is ViewBag, ViewData and TempData in Asp.Net MVC and I hope you will refer this article for your need. Stay tuned and stay connected for more technical updates.

Free Trial ASP.NET 4.5.1 Hosting - with :: How to make Scrollable GridView with a Fixed Header in .NET 4.5.1

clock March 7, 2014 05:38 by author Diego

In this article I will explain how to implement scrollable gridview with fixed header in using JQuery. GridView control of ASP.NET 4.5.1 makes our task much simpler as compared to HTML tables. But one problem which I always faced with GridView control is of scrolling headers. I tried several forums and websites, but didn’t come up with a good solution. GridView doesn’t have the ability to scroll. But if the GridView contains the larger number of rows or columns (say more than 100 rows and 15 columns), we want it to have scrollbars.

Now it is time to see all the activity in detail :

  • create a database in the SQL ServerCreate an ASP.NET website.
  • Create jquery-1.4.1.min.js and ScrollableGridPlugin.js and write this code in the header section. copy and paste it inside  <Head>.
    These script files by using these files we can manage the GridView header fixed postion.

    script type="text/javascript" src="Scripts/jquery-1.4.1.min.js"></script>

    script type="text/javascript" src="Scripts/ScrollableGridPlugin.js"></script>
  • Write the jQuery code that is given below.

            $(document).ready(function () {
                $('#<%=GridView1.ClientID %>').Scrollable();


  • The next step is to create a new HTML table in HeaderDiv which will contain the new header for the GridView. This job will be done by a JavaScript function (say CreateGridHeader()). This JavaScript function also sets the HeaderDiv style as per the DataDiv and new HTML table style as per GridView style and also we will hide the original header of GridView. This function will be called every time after filling the GridView with data as well as on the Page Load.
    created in the Page Load Default.aspx page like this :

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
html xmlns="">
head runat
    <title>Scrollable GridView With a Fixed Header Using jQuery</title>
    <script type="text/javascript" src="Scripts/jquery-1.4.1.min.js"></script>
script type="text/javascript" src="Scripts/ScrollableGridPlugin.js"></script>
script type="text/javascript">
        $(document).ready(function () {
            $('#<%=GridView1.ClientID %>').Scrollable();
    <form id="form1" runat="server">
    <asp:GridView runat="server" ID="GridView1" AutoGenerateColumns="false">
        <RowStyle BackColor="#EFF3FB" />
        <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
        <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
        <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
        <AlternatingRowStyle BackColor="White"
            <asp:BoundField DataField="id" HeaderText="Id" />
            <asp:BoundField DataField="name" HeaderText="Name" />
            <asp:BoundField DataField="salary" HeaderText="Salary" />\
            <asp:BoundField DataField="addres" HeaderText="Address" />


  • Binding the GridView with a DataTable object in the code behind file of Default.aspx page.


    partial class Default2 : System.Web.UI.Page
        protected void Page_Load(object sender, EventArgs e)
            SqlConnection con = new SqlConnection(@"Data Source=.;Initial Catalog=akshay;Persist Security Info=True;User ID=sa;Password=wintellect";
            SqlDataAdapter adap = new SqlDataAdapter("select * from Person",con);
            DataSet ds=new DataSet();
            GridView1.DataSource = ds.Tables["Person"];
            GridView1.UseAccessibleHeader = true;
            GridView1.HeaderRow.TableSection = TableRowSection.TableHeader;

  • Run the Page by f5, you will see that the Header and Footer is fixed when you scrolling. You are now ready with the GridView with fixed headers.

If you looking for windows web hosting services who support ASP.Net 4.5.1 please visit our Site

ASP.Net Hosting – :: How to Use NumericUpDownExtender in ASP.Net AJAX

clock February 24, 2014 05:09 by author Diego

NumericUpDown is an ASP.NET AJAX extender that can be attached to an ASP.NET TextBox control to add "up" and "down" buttons that increment and decrement the value in the TextBox. The increment and decrement can be simple +1/-1 arithmetic, they can cycle through a provided list of values (like the months of the year), or they can call a Web Service to determine the next value. Page authors can also provide custom images to be used instead of the default up/down button graphics. In this article, I will show you step by step procedure, how to use a Up Down Extender

In ASP.NET using Visual Studio 2005 or Visual Studio 2008.

Step 1 : Open Visual Studio.

  • Go to File->New->WebSite
  • Select ASP.NET WebSite

Step 2 :

Under Visual Studio Installed Template-> Choose ASP.NET WEB SITE -> Choose File System from the location combo box -> Set the path by the browse button - > Choose the language from the Language ComboBox (Visual C# , Visual Basic , J #)

  • Choose Visual C#

Step 3 :

Click on the OK Button.
This is the source code window :

Step 4 :
See here is a tab named Design in the bottom of this page. Click on this tab and you will see a blank web page where you can drag any control from the toolbox (which is in the left side of this window).

Step 5 :
Now drag some controls under the AJAX Extensions. First control you are going to drag and drop on the page is - Script Manager.

  • first add a tag on the top of your source code window:
    <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
  • Under the form tag,NumericUpDownExtender control

Step 6:

Now run the application by pressing ctrl +  F5.

Step 7 :

When you run the Up Down Extender will seem like this...


ASP.Net Hosting – :: Adding Email Confirmation to ASP.NET Identity in MVC 5

clock February 19, 2014 09:14 by author Diego

One of the mainline features about ASP.NET Identity is to make it easy to Adding Email Confirmation. This process will send an email to the user with a link they can click on to confirm their registration and log in to the system. Prior to confirmation they will not be able to log in.


This post shows how you can adding email confirmation to ASP.NET Identity in MVC 5.

First I started by creating a new MVC 5 application.  You no longer select whether you want an Internet or Intranet application, you just select the MVC template and select the authentication type you want to use. For an Internet type application you select Individual User Accounts.  Once your web application is created open IdentityModels.cs in the Models directory.  You will see a class called ApplicationUser which is analogues to the UserProfile in SimpleMembership.  It is an empty class that inherits from IdentityUser which has these properties.

You must to modify the user information to store a the confirmation token and a flag indicating whether confirmation was completed or not.

Now let’s implement the method in the AccountMembershipService class:


Here, we’re setting the confirmationGuid to user. This is the GUID stored in the database that uniquely identifies the user. We then set the verifyUrl to the Verify action on the Account controller – passing the confirmationGuid as the ID parameter. The redirect to the RegisterStepTwo action just displays a view to the user that tells them to look for the email to complete the registration process.

Once the user gets the email they click on the link that will take us back to the controller action RegisterConfirmation. With that configured, when the user clicks the register button, they’ll be sent an email with the confirmation link it, and they’ll be redirected to the confirmation page. If we find a user we set IsConfirmed to true and return true from the method; otherwise we return false. If the user is confirmed they will be able to log in.

That is all there is to setting up email confirmation using ASP.NET Identity in MVC 5.


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

 photo ahp banner aspnet-01_zps87l92lcl.png


Corporate Address (Location)

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

Tag cloud

Sign in