Windows 2012 Hosting - MVC 6 and SQL 2014 BLOG

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

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.



SQL 2012 Hosting with ASPHostPortal.com :: How to Make Connection String in C# with SQL Server 2012

clock March 3, 2014 10:17 by author Diego

How to I create database with C#? And how to I set Connection String in C# with SQL Server 2012 ? . In this article I will explain how to write connection strings. I have one web application that contains many pages and each page contains relationship with database connection to get data from database and display it on page because of that I need to write database connections for each page to interact with database. Now the server name or credentials of database server has changed in that situation it will create problem because we need to modify the database connections of each page using asp.net.

Two Type of SqlConnection String First for sql file and Second for sql server you have to almost use 2nd type. Passing IP address of Database server , database name , User id & password.

write the following code in code behind :

Standard Connection

using System.Data.SqlClient;
SqlConnection conn = new SqlDbConnection();

Server name or ip address is come there , Initial Catalog for Database name;UserName for user id and secret for password // is sql user id and password by defaul sql user is 'UserName' and password you should be set it

conn.ConnectionString ="Data Source=ServerName; Initial Catalog=DataBaseName; User id=UserName; Password=Secret;";
conn.Open();

Or u can try this one for Trusted Connection :

conn.ConnectionString ="Data Source=ServerName; Initial Catalog=DataBaseName; User id=UserName; Password=Secret;";conn.Open();using System.Data.SqlClient;SqlConnection conn = new SqlConnection();conn.ConnectionString = "Data Source=ServerName; Initial Catalog=DataBaseName; Integrated Security=SSPI;";
conn.Open();



About ASPHostPortal.com

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

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


Author Link


Corporate Address (Location)

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

Sign in