Windows 2012 Hosting - MVC 4 and SQL 2012 BLOG

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

nopCommerce 3.30 Hosting with ASPHostPortal.com :: How to Enable SSL (https) in nopCommerce

clock April 14, 2014 08:19 by author Kenny

nopCommerce is one of the most popular ASP.NET shopping cart applications which you can use it for designing your business website for free. nopCommerce is an open source e-commerce solution that contains both a catalog frontend and an administration tool backend. nopCommerce is a fully customizable shopping cart. It's stable and highly usable. From downloads to documentation, nopCommerce.com offers a comprehensive base of information, resources, and support to the nopCommerce community. nopCommerce is a complete open source shopping cart softare, the first edition was released in October 2010, we can say this is still a very new shopping cart application in the market, but their users are growing super-fast in the past 3 years. nopCommerce is a fully customizable shopping cart and you can easily installed it in your hosting account. You just need to download the instalaltion file from official website and use FTP to upload it into your hosting server and unzip the file, then you have to create MSSQL 2005 or 2008 database, and you can install it for your website now.

As the Internet grows as a medium of communication, commerce and interaction, so do the prevalence of risks and security threats. One way to effectively protect your domain is with an SSL certificate. The primary reason why SSL is used is to keep sensitive information sent across the Internet encrypted so that only the intended recipient can understand it. This is important because the information you send on the Internet is passed from computer to computer to get to the destination server. Any computer in between you and the server can see your credit card numbers, usernames and passwords, and other sensitive information if it is not encrypted with an SSL certificate. When an SSL certificate is used, the information becomes unreadable to everyone except for the server you are sending the information to. This protects it from hackers and identity thieves.

In this article, i'm going to explain about how to enable SSL in nopCommerce, you will first need to purchase an SSL certificate and dedicated IP. This article assumes that you already purchase an SSL from SSL provider.

  • Install SSL on your web server
  • Open web.config file
  • Set UseSSL value to true (<add key=”UseSSL” value=”true” /> )
  • Then just save the file.

nopCommerce automatically switched to SSL when required ( for example, register, login and checkout admin ect.)

Get SharedSSLUrl from your hosting provider
Open the web.config and edit the following values

<add key=”UseSSL” value=”true” />
<add key=”SharedSSLUrl” value=”https://secure.yourhostingcompany.com/~username” />
<add key=”NonSharedSSLUrl” value=”https://secureyourhostingcompany.com/~username” /> 


ASP.NET 4.5 Cloud Hosting with ASPHostPortal.com:: How to Build and Rebuild Your ASP.NET Applications in Cloud Hosting

clock April 10, 2014 11:39 by author Ben

One of the big buzzwords these days is "Cloud".  I see it on TV commercials during football games all the time and often wonder if 99% of the audience has any clue what the commercial is actually talking about.  The cloud is essentially a hosting service where you can host your databases or web sites.  It is a cost-efficient way of getting applications up and running without investing a lot of money in infrastructure.  this article will show you how to build and rebuild ASP.NET web application to the cloud hosting.

Note: User has administration access to the website

Here is step by step how to build and rebuild your ASP.NET application in cloud hosting:

Login to the Classic Cloud Control Panel

If you are new to ASPHostPortal Cloud, please refer to Adding a new website and add the website.

NOTE: The domain must have .Net and Asp technology Feature enabled. This can be verified and changed if necessary in the Features tab of the domain as shown below.

Navigate to Hosting -> Cloud Sites -> This will list all the domains/websites owned by the account and click on the website to be updated.

Create the following two files:

1. First_asp_page.asp - This is a simple ASP page

<html>

 <head>

 <title>My First ASP Page</title>

 </head>

 <body bgcolor="white" text="black">

 <%

   'Dimension variables

   Dim strMessage                                           

   strMessage = "Hello World"

   Response.Write (strMessage)

   Response.Write ("

")

   Response.Write ("The time on the server is: " & Time())

 %>

 </body>

 </html>

2. web.config - This is the configuration file. Fill in your username and password to allow impersonation. Refer to MSDN for more information

 <?xml version="1.0" encoding="utf-8" ?>

 <configuration>

   <system.web>

    <identity impersonate="true" userName="dfw\YOURNAME" password="YOURPASSWORD" />

   </system.web>

 </configuration>

Verify that logging is turned on if needed. Refer to Enable logging for a website

Upload the two files created to the main directory of the website using one of the following two methods

ftp - Refer to Upload content to a website using FTP

File Manager - Refer to Upload content to a website using the File Manager

Navigate to the First_asp_page.asp using the Test URL if necessary. Refer to Use a staging URL. Ensure that it is served by Cloud Sites.

You can rebuild your ASP.NET Application. There are two methods you can use the rebuild the application in IIS.

The first method is to use the Rebuild App link in the General Settings tab of your Classic Cloud Control Panel. To access this just go to Hosting -> Cloud Sites -> Click on the website in question -> Then scroll down and you should see the Rebuild App link to the right.

The second method is to simply delete and reupload your web.config file.

Our Special ASP.NET 4.5.1 Hosting Complete Features
24/7 Monitoring

We do 24/7 monitoring of your ASP.NET to make sure that we proactively kill any trouble. This helps to ensure maximum uptime and performance.

Easy-to-use service (1-click installs)
ASPHostPortal.com gives you access to all SimpleScripts features, provides easy one-click installation and management of all popular applications.


Fast and Secure Server

Our powerfull servers are especially optimized and ensure the best ASP.NET 4.5.1 performance. We have best data centers on three continent and unique account isolation for security.


Daily Backup Service

We realise that your website is very important to your business and hence, we never ever forget to create a daily backup. Your database and website are backup every night into a permanent remote tape drive to ensure that they are always safe and secure. The backup is always ready and available anytime you need it.



ASPHostPortal.com Proudly Announces SQL Server 2014 Hosting

clock April 8, 2014 08:19 by author Ben

ASPHostPortal.com, a reliable web hosting company specializing in ASP.NET hosting services, announces the deployment of SQL Server 2014 in its web hosting packages.

ASPHostPortal.com now provides the SQL Server 2014 in all of web hosting packages, assisting all their web hosting customers on organizing, improving and securing business’ data. Making business decisions are the crucial steps that businesses need to take, mostly in short time. It requires accessing company’s data in easy manner to be analyzed and evaluated. The SQL Server 2014 has the excellent tool to do this. With the Power View, businesses will be able to excerpt data into PowerPoint presentations and bring updated information in every meeting.

 


Businesses are often must face complicated issues, whether it occurs inside the organization or related to clients and customers. For example, clients often want their data quality being improved regularly that can be a challenging task. With the SQL Server 2014 this process can be reduced this problem since it has the ability to enhance the consistency and accuracy of the data. The SQL Server 2014 works by cleaning out the data thus resulting in superior quality and enduring maintenance.

The basic shared hosting service is supported by SQL Server 2014 web hosting and the site provides this plan at a monthly cost of $5. The site assures a 24x7 customer support service and guarantees a 99.9% uptime as they have installed fully servers. The company through its website gives all its customers a Plesk Panel which is basically server management software.

“Our customers have been asking us about SQL Server 2014 and we are happy to deliver a hosting platform that supports all the latest in the Microsoft Web Stack.” said said Dean Thomas, Manager at ASPHostPortal.com.  "And it proves that we remain at the forefront in Microsoft technology".

ASPHostPortal.com is a popular SQL Server 2014 hosting service provider with all of its  hosting plans to help users to automate and simplify website and server administration tasks such as  installation and migration. For more information about this topics or have any enquiries related to SQL Server 2014 hosting,  please visit http://asphostportal.com/SQL-2014-Hosting.

ASPHostPortal.com is now providing this FREE DOMAIN and DOUBLE SQL Space promotion link for new clients to enjoy the company's outstanding web hosting service at a low cost from just $5.00/mo. This offer valids only from 21st March 2014 to 20 April 2014 and it applies to all the new clients registered during these dates only.

About ASPHostPortal.com:

ASPHostPortal.com 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.com 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.



Reporting Services Hosting with ASPHostPortal :: Integrating Reporting Services Into a Web Application

clock April 4, 2014 13:12 by author Kenny

With Visual Studio you can be easier to integrate SQL Reporting Services into ASP.NET web applications. Now, i will explain about how to integrate Report Services into a web application using Visual Studio.

First, you must create a new project in Visual Studio, in the ASP.NET code, you will need to delete (or change) this line:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

Next replace any existing code between the <form> tags with the below code:
<table style="vertical-align: bottom; border-width: 0px; margin-top: 0px;
   margin-bottom: 0px; width: 100%; height: 100%; padding: 0px,0px,0px,0px;"
   cellspacing="0" cellpadding="0">
    <tr>
        <td>
            HEADER
        </td>
    </tr>
    <tr>
        <td>
            <div style="border-top: black 1px solid;
                background-color: #ece9d8; border-bottom-width: 1px;
                border-bottom-color: #d4d0c8; padding-bottom: 10px;">
                Custom Controls
            </div>
       </td>
    </tr>
    <tr>
        <td style="height: 100%;">
            <%-- This is where the ReportViewer control will go. --%>
        </td>
    </tr>
</table>


Switch to the “Design” view since it is now time to add the ReportViewer control.
In the “Data” section within the Toolbox, drag the ReportViewer control onto the last row of your table, which should be taking up most of the page. Next you want to set the control’s properties so that it points to the right server and the right report. Under properties, go to the “Server Report” section. Right above the section you should see a property called “ProcessingMode”. In most cases you are going to want use an instance of a Report Server. So for the purposes of this tutorial, set this property to “Remote”, even if the Report Server instance is on the same computer as your web app. Next, you want to set the “ServerReport” settings.

First, type in address of the Report server in the “ReportSeverUrl” field.
The syntax is:
http:// NameOfServer / reportserver
i.e. http://ServerOne/reportserver

Next type in the location of the report in the “ReportPath” field.
i.e. /MyReports/TheReport

The location is easy to know since it is the same path structure that you see in the Report Manager. Also, always be sure the put a forward slash first before the actual path.

Unless you want the ReportViewer to be an absolute size, go ahead and set the height and width settings under the “Layout” section to be 100%. The ReportViewer will by default show controls to set the parameters for the report. These often look a little ugly, and I would recommend most developers to create their own parameter controls. This can be done in the control bar row of the template provided above. To get rid of the ReportViewer’s parameter controls set the “ShowParameterPrompts” in the properties underneath “Appearance” to false. In, the next section I’ll show how you can set the report parameters with your own code.

Those should be all the settings you need to make for the ReportViewer to display correctly, unless your version of Visual Studio has other default settings. Double check to make sure the ASP.NET looks similar to this code:
<rsweb:ReportViewer ID="ReportViewer1" runat="server" Height="100%"
    ProcessingMode="Remote" ShowParameterPrompts="False" Width="100%">
    <ServerReport ReportPath="/MyReports/TheReport" />
</rsweb:ReportViewer>

Now, the report is ready to be processed. You can go ahead and preview your website and the report should generate just fine.



Free Trial ASP.NET MVC 5 Hosting :: ASP.NET MVC 5 and Bootstrap 3 CSS Framework

clock March 19, 2014 07:39 by author Kenny

ASP.NET MVC 5 uses Bootstrap 3 as the CSS Framework in its default ASP.NET Web Application Tempate. This is a nice touch as most ASP.NET MVC developers have at least played with Bootstrap and are designing responsive websites. I'll mention the use of Bootstrap here briefly as there really isn't much to it.

When you create a new ASP.NET MVC 5 Web Application in Visual Studio 2013 it is using Bootstrap 3 as its default CSS Framework. You get the pleasure of the responsive navigation and website along with all the typography and other bells and whistles you expect from Bootstrap 3.

Inside the ASP.NET MVC 5 Website Template you will find the bootstrap.css and bootstrap.min.css stylesheets as well as the bootstrap.js and bootstrap.min.js scripts. The _Layout.cshtml view and other views are marked up appropriately using the CSS selectors in Bootstrap 3.
By default, the ASP.NET MVC Website Template uses a couple of bundles that use both Bootstrap 3 CSS as well as Modernizr. Check out the Layout.cshtml view to see the use of two of the bundles.
  @Styles.Render("~/Content/css")
  @Scripts.Render("~/bundles/modernizr")


You will find these bundles configured in the BundleConfig.cs file in App_Start.
  bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
    "~/Scripts/modernizr-*"));

  bundles.Add(new StyleBundle("~/Content/css").Include(
    "~/Content/bootstrap.css",
    "~/Content/site.css"));

And, of course, the CSS selectors and markup in the new ASP.NET MVC 5 Views are based on Bootstrap 3.
This isn't a huge deal, but it's still nice to see ASP.NET MVC 5 using Bootstrap 3 by default. Certainly, you can remove it for Foundation, Skeleton, or other CSS and JavaScript Framework of your choice.



FREE Trial SQL 2012 Hosting - with ASPHostPortal.com :: New Security Features SQL Server 2012

clock March 18, 2014 12:12 by author Diego

Microsoft SQL Server 2012 continues this trend with an extensive collection of new security features and enhancements. These enhancements not only help organizations to improve access controls to data, but also to achieve the highest level of data protection and compliance. Also, these features help make SQL Server arguably the most robust common database platform from a security perspective, with less vulnerability and fewer security patches needed to maintain the system.

SQL Server 2012 has many new security features, and three of the bigger new features are: Default Schema for Windows Groups, Audit enhancements, and User-Defined Server Roles.

Default schema for Windows groups
A database schema can now be tied to a Windows Group rather than an individual user in order to increase database compliance.  This makes it easier to administer database schemas, decreases the complexity of database schema management through individual Windows users, prevents errors of assigning a schema to the wrong user when a user changes groups, avoids unnecessary implicit schema creation, and by reducing the chances of choosing the wrong schema then it greatly reduces the chance of query errors.

Before SQL Server 2012 was introduced, it was not possible to specify the default schema for Windows groups. As a result, when the user getting access through Windows group membership created database objects such as a table or view inside a database, SQL Server automatically created a separate user (mapped to the admin account) and a schema with the same name in the database. Because of this security manageability issue, we end up having hundreds of users and schemas inside databases, which caused administrative challenges and is a managerial nightmare for administrators. Hence, SQL Server community requested a fix for this security issue via the Microsoft Connect site.

Luckily, SQL Server 2012 addresses this security issue by allowing us to assign a default schema for Windows Groups, which helps organizations simplify their database schema administration.

The following Transact SQL (T-SQL) demonstrates the process of assigning the default schema for Windows Group:

-- Creating Default Schema "ProdAdmins" for Windows Group "MyDomain\ProdDBAs"
CREATE SCHEMA [ProdAdmins] AUTHORIZATION [MyDomain\ProdDBAs]
GO


-- Set Default Schema for Windows Group "MyDomain\ProdDBAs"
ALTER USER [MyDomain\ProdDBAs] WITH DEFAULT_SCHEMA=[ProdAdmins]
GO

Audit Enhancements
Server and database audit specification objects found in SQL Server 2008 and SQL Server 2008 R2 are the most useful features of SQL Server and help the organization meet various regulatory compliance requirements. The problem with these auditing features is that they were only in the enterprise edition.

Fortunately, the server level audit specification features are now supported by all versions of SQL Server 2012. Audit specification features of SQL Server 2012 are more resilient to failures with writing to the audit log, and it is possible to limit the number of audit log files without rolling over. SQL Server 2012 audit specification features also support user-defined groups, which means we can now write audited events to the audit log by using sp_audit_write (Transact-SQL) procedure. Finally, SQL Server 2012 supports the ability to filter the audit events and include new audited groups to monitor contained database users.

User-Defined Server Roles
User-Defined Server Roles increase flexibility, manageability, and facilitates compliance towards better separation of duties.  It allows creation of new server roles to suit different organizations that separate multiple administrators according to roles.  Roles can also be nested to allow more flexibility in mapping to hierarchical structures in organizations.  It also helps prevent organizations from using sysadmin for database administration. We can use CREATE SERVER ROLE, ALTER SERVER ROLE and DROP SERVER ROLE Transact-SQL statements to create, alter and drop user-defined server roles. This is demonstrated as follows:

-- Creating user-defined roles
CREATE SERVER ROLE [JuniorDBA]


-- Granting server-wide permissions

GRANT CREATE ANY DATABASE TO [JuniorDBA]

-- Adding members to user-defined roles
ALTER SERVER ROLE [JuniorDBA]
ADD MEMBER [Domain\JuniorDBA_Group1]
ALTER SERVER ROLE [JuniorDBA]
ADD MEMBER [Domain\JuniorDBA_Group1]

-- Making user-defined role member of fixed server role ALTER SERVER ROLE [processadmin]
ADD MEMBER [JuniorDBA]


-- Dropping user-defined roles
DROP SERVER ROLE [JuniorDBA]



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

clock March 14, 2014 12:02 by author Diego

ASPHostPortal.com, 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 altruistic.ASPHostPortal.com 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.

ASPHostPortal.com is proud to offer a FREE Trial Windows Hosting. We believes in try it before buy it. We are completely confident in our windows 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 Windows 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 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 [email protected] or send us a tweet @asphostportal

About Us

ASPHostPortal.com 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 4 Hosting - with ASPHostPortal.com :: Retrieving Image From SQL via Image Path in ASP.NET

clock March 13, 2014 12:04 by author Diego

In this article, we will explore how to store images in the database with the help of FileUpload Control and also how to display those images in asp.net GridView Control. For the purpose of this article I have created a table in SQL Server called Images, with three columns, Image Name, Image Type and the Image itself. Now let’s take a look at the form we are going to use, to upload images to this table.
The concept behind this technique is to store the images on disk in a folder that resides in the WebSite root directory while the relative path of the images along with filename is stored in SQL Server database.

Let us start off by first creating a sample database and adding a table that will store the image path. The figure below describes the table structure.
set the ID field to auto increment using the identity property.

Next I’ll add a FileUpload and Button to the aspx page.
<div>
    <asp:FileUpload ID="FileUpload1" runat="server"/>
    <asp:Button ID="btnUpload" runat="server" Text="Upload"
        OnClick="btnUpload_Click" />

</div>

Adding a folder called "images" in my website root directory.
Adding a connection string key to the web.config which will be used to connect to the SQL server Database.
<connectionStrings>
  <add name="conString"

     connectionString="Data Source=.\SQLEXPRESS;database=GridDB;
       Integrated Security=true"/>
</connectionStrings >

Upload and Storing the Image Files. The snippet below gets executed when the upload button is clicked. It gets the uploaded image filename and saves the image in images folder. And then inserts the image file path into the database.protected void btnUpload_Click(object sender, EventArgs e){
    if (FileUpload1.PostedFile != null)

    {

        string FileName = Path.GetFileName(FileUpload1.PostedFile.FileName); 

        //Save files to disk

        FileUpload1.SaveAs(Server.MapPath("images/" +  FileName));

        //Add Entry to DataBase

        String strConnString = System.Configuration.ConfigurationManager

            .ConnectionStrings["conString"].ConnectionString;

        SqlConnection con = new SqlConnection(strConnString);

        string strQuery = "insert into tblFiles (FileName, FilePath)" +

            " values(@FileName, @FilePath)";

        SqlCommand cmd = new SqlCommand(strQuery);

        cmd.Parameters.AddWithValue("@FileName", FileName);

        cmd.Parameters.AddWithValue("@FilePath", "images/" + FileName); 

        cmd.CommandType = CommandType.Text;

        cmd.Connection = con;

        try

        {

            con.Open();

            cmd.ExecuteNonQuery();

        }

        catch (Exception ex)

        {

            Response.Write(ex.Message);

        }

        finally

        {

            con.Close();

            con.Dispose();

        }

    }

}

Display Images. Now the next job is to display the images in GridView control. As you can see the below GridView, I have added 2 Bound Fields which displays ID and File Name and a Image Field which displays the image based on the image path that comes from the database.
<div>
<br />

    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns = "false"

       Font-Names = "Arial" >

    <Columns>

       <asp:BoundField DataField = "ID" HeaderText = "ID" />

       <asp:BoundField DataField = "FileName" HeaderText = "Image Name" />

       <asp:ImageField DataImageUrlField="FilePath" ControlStyle-Width="100"

        ControlStyle-Height = "100" HeaderText = "Preview Image"/>

    </Columns>

    </asp:GridView>

</div>

The snippet below is used to display the images in the GridView control. As you will notice I am firing a simple select query and the returned datatable is then bind to the GridView Control.

protected void Page_Load(object sender, EventArgs e)
{

    DataTable dt = new DataTable();

    String strConnString = System.Configuration.ConfigurationManager.

        ConnectionStrings["conString"].ConnectionString;

    string strQuery = "select * from tblFiles order by ID";

    SqlCommand cmd = new SqlCommand(strQuery);

    SqlConnection con =  new SqlConnection(strConnString);

    SqlDataAdapter sda = new SqlDataAdapter();

    cmd.CommandType = CommandType.Text;

    cmd.Connection = con;

    try

    {

        con.Open();

        sda.SelectCommand = cmd;

        sda.Fill(dt);

        GridView1.DataSource = dt;

        GridView1.DataBind(); 

    }

    catch (Exception ex)

    {

        Response.Write(ex.Message);

    }

    finally

    {

        con.Close();

        sda.Dispose();

        con.Dispose();

    }

}

The GridView with images is shown in the figure below.

I hope you will enjoy reading this article you should have learned how to Retrieve images using a file path stored in database in ASP.Net that you can use in your own code. Stay tuned and stay connected for more technical updates with ASPHostPortal.



Cheap ASP.Net MVC 5 Hosting - with ASPHostPortal.com :: Creating a new custom Authentication Filter with ASP.NET MVC 5

clock March 7, 2014 07:28 by author Diego

ASP.NET MVC 5 included with the recently released Visual Studio 2013 Developer Preview enables developers to apply authentication filters which provides an ability to authenticate users using various third party vendors or a custom authentication provider. However, these filters are applied prior to invoking of authorization filters. If you have used ASP.NET MVC before, you probably have used AuthorizationFilters. Authorization filters allow you to perform authorization tasks for an authenticated user. A good example is Role based authorization. When you authenticate a user, you are verifying the identity of a user. If you need to verify a user in an MVC application it is  probably because you are building an application that restricts access to specific users. This is completely separate from authorization, which is determining whether a specific person is allowed to do certain action.

In this article i would like to explain how to use the new Authentication Filters included in the ASP.NET MVC 5 preview.
Here i am explaining about.

  • Create New Project. Open Visual Studio 2010 >> New Project >> Select ASP.NET MVC5 Web Application and Click Ok, Then select MVC for the ASP.NET project type.

  • In order to create an Authentication filter, you must implement the IAuthenticationFilter. Below is the implementation of ASP.NET MVC’s IAuthenticationFilter.
    public class BasicAuthAttribute: ActionFilterAttribute, IAuthenticationFilter.

  • Create the OnAuthenticationChallenge method accepts AuthenticationChallengeContext argument and its implentation looks like as shown below :
    public void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext)
    {

    var user = filterContext.HttpContext.User;

    if (user == null || !user.Identity.IsAuthenticated)

    {

    filterContext.Result = new HttpUnauthorizedResult();

    }

    }

  • write this code for BasicAuthAttribute implementation:
    using System.Web.Mvc;
    using System.Web.Mvc.Filters;

    namespace VSMMvc5AuthFilterDemo.CustomAttributes
    {
    public class BasicAuthAttribute : ActionFilterAttribute, IAuthenticationFilter
    {

    public void OnAuthentication(AuthenticationContext filterContext)
    {}
    public void OnAuthenticationChallenge(AuthenticationChallengeContext filterContext)
    {
    var user = filterContext.HttpContext.User;

            if (user == null || !user.Identity.IsAuthenticated)
            {
                filterContext.Result = new HttpUnauthorizedResult();
            }
        }
    }
}

If you look at the above CustomAuthenticationAttribute, there are two interesting methods required to implement.

  1. OnAuthentication. This method creates an AuthenticationContext using the original principal, and executes each filter’s OnAuthentication method.
  2. OnAuthenticationChallenge. This method runs after the OnAuthentication method. You can use OnAuthenticationChallenge method to perform additional tasks on the request.
    Note : The key thing to remember is that OnAuthenticationChallenge does not necessarily run before every other Action Filter. It can run at various stages.

The new IAuthenticationFilter provides a great ability to customize authentication within an ASP.NET MVC 5 application. This provides a clear separation between authentication and authorization filters. OnAuthentication and OnAuthenticationChallenge methods provide greater extensibility points to customize authentication within ASP.NET MVC framework.

  • The BasicAuthAttribute class can be easily tested by applying it to the HomeController class by opening the file and adding the following line of code :
    using VSMMvc5AuthFilterDemo.CustomAttributes;

  • Here we execute the CustomAuthenticationAttribute only for HomeController’s class as shown below :
    BasicAuthAttribute]
    public class HomeController : Controller

  • The last, when you run the application, you should now be automatically redirected to:

The login page.

Register Page.

Once your user is registered, you'll be automatically redirected to the homepage.

If you looking for windows web hosting services who support ASP.Net MVC 5 please visit our Site ASPHostPortal.com

 

 



ASPHostPortal Web Hosting - Great Improvements from SQL Server 2005 until SQL Server 2014

clock March 4, 2014 10:20 by author Diego

Many New Features have been provided with the New SQL Server 2014. Microsoft SQL Server 2014 brings to market, new in-memory capabilities built into the core database, and provides new cloud capabilities to simplify cloud adoption for your SQL databases and help you unlock new hybrid scenarios. In this Blog I had provided these features in the way of difference between the older and New version of SQl Server.

 

New features or changes to existing features in Microsoft SQL Server 2014.

  • Memory-optimized Tables.  will help you quickly analyze your tables and walks you through reviewing and migrating disk-based table to In-Memory OLTP tables.
  • SQL Server Backup to URL
  • Encryption for Backups
  • New Design for Cardinality Estimation
  • Delayed Durability
  • AlwaysOn Enhancements
  • Business Intelligence Enhancement

The older version 2005, 2008 and 2012

  • SQL Server AlwaysOn. A high availability solution that increases application availability while also lowering total cost of ownership and making it easier to use.
  • Contained Databases, which intends to reduce or eliminate the dependencies that a database has on the SQL Server instance, making it easier to migrate a database to a new instance with less of the work involved in reproducing and validating these dependencies.
  • Web Development and Business Intelligence Enhancements. While business intelligence features were upgraded in SQL Server 2008 R2, Microsoft really improved Excel PowerPivot by adding more drill and KPI through.
  • ColumnStore Indexes. What a ColumnStore index does is essentially turn a traditional index on its side.
  • SQL 2008 also allows you to disable lock escalation on specific tables.
  • Transparent Database Encryption.  The ability to encrypt an entire database without having to change any code in your application adding an additional layer to your data security.
  • Intellisense in SQL Server Management Studio. Interactive help as you type giving object names and syntax support similar to Visual Studio.
  • In SQL 2005, even with the ROWLOCK hint on delete statements locks can be escalated which can lead to deadlocks. In my testing, an application which I have developed had concurrency issues during small table manipulation due to lock escalation on SQL 2005. In SQL 2008 this problem went away.

The new features are really great and its meets the very important factors of current age. For .Net people it's always be a boon to use SQL Server, I hope using the latest version we will have better security and better performance as well as the introduction of compression the size of the database. The backup encryption utility is also phenomenon.
Once again thanks to Microsoft for their great thoughts in form of software.



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


Corporate Address (Location)

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

Sign in