Tuesday, 16 June 2015

Rank, Dense_Rank and Row_Number



RANK()

Returns the rank of each row in the result set of partitioned column.
select Name,Subject,Marks,
RANK() over(partition by name order by Marks desc)Rank
From ExamResult
order by name,subject

Rank() Example

DENSE_RANK()

This is same as RANK() function. Only difference is returns rank without gaps.
select  Name,Subject,Marks,
DENSE_RANK() over(partition by name order by Marks desc)Rank
From ExamResult
order by name

DENSE_RANK() Example
In RANK() result set screenshot, you can notice that there is gap in Rank(2) for the name Sam and same gap is removed in DENSE_RANK().

NTILE()

Distributes the rows in an ordered partition into a specified number of groups.
It divides the partitioned result set into specified number of groups in an order.

Example for NTILE(2)

select Name,Subject,Marks,
NTILE(2) over(partition by name order by Marks desc)Quartile
From ExamResult
order by name,subject

NTILE(2) Example

Example for NTILE(3)

select Name,Subject,Marks,
NTILE(3) over(partition by name order by Marks desc)Quartile
From ExamResult
order by name,subject

NTILE(3) Example

ROW_NUMBER()

Returns the serial number of the row order by specified column.
select Name,Subject,Marks,
ROW_NUMBER() over(order by Name) RowNumber
From ExamResult
order by name,subject
 ROW_NUMBER() Example

Friday, 12 June 2015

Web API in MVC

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using abc.Models;
using System.Data;
using System.Xml;
using System.Net.Http;
using Newtonsoft.Json;
using System.Net.Http.Headers;
using System.Threading.Tasks;  

 public  ActionResult LoginUser(Loginguser log)
        {
            if (ModelState.IsValid)
            {
                try
                {                                      
                       HttpClient webClient1 = new HttpClient();
                       string pass = log.password;

                       //Uri uri = new Uri("http://m.abc.com/service/userprofile.svc/logIn?loginId=" + log.username + "&pass=" + log.password);
                       Uri uri = new Uri("http://m.vinipost.com/service/userprofile.svc/logInUsrTyp?loginId=" + log.username + "&pass="+pass +"&usrTyp=1");
                       var response1 = webClient1.GetAsync(uri).Result;



                       var jsonString = response1.Content.ReadAsStringAsync().Result;

                        string[] x = jsonString.Split('[');
                        string[] y = x[1].Split(']');
                        string res = "[" + y[0] + "]";

                        var _Data = JsonConvert.DeserializeObject<List<JClass>>(res);
                        string msg = null;                    
                        string Name = null;

                        foreach (JClass Student in _Data)
                        {
                           msg = Student.msg;
                           Name = Student.Name;
                        }

                      if(msg!=null)
                      {
                          ViewBag.reg = msg;
                          return View();
                      }
                      Session["Username"] =Name;
                      if (Session["Reviewuser"] != null)
                              {
                                 string id = Session["Reviewuser"].ToString();
                                 if (globevar.cid == 1)
                                  {
                                     return RedirectToAction("CabShows", "CabService");
                                  }
                                  return RedirectToAction("Reviews", "Review", new { id1 = id });
                             }
                             else
                                 return RedirectToAction("Show", "User");


                     /* Connection obj = new Connection();
                      DataSet ds = new DataSet();
                      string pass = log.password.ToString();//globevar.Decryptdata(log.password.ToString());
                      string s = "select U_Type from User_Master where U_Name='" + log.username.ToString() + "' and U_Password='" + pass.ToString() + "'";
                      ds = obj.Getdata(s);
                      if (ds.Tables[0].Rows.Count > 0)
                      {
                          Session["Username"] = log.username.ToString();
                          if (Session["Reviewuser"] != null)
                          {
                              string id = Session["Reviewuser"].ToString();
                              if (globevar.cid == 1)
                              {
                                  return RedirectToAction("CabShows", "CabService");
                              }
                              return RedirectToAction("Reviews", "Review", new { id1 = id });
                          }
                          else
                              return RedirectToAction("Show", "User");
                      }
                      else
                      {
                          ViewBag.reg = "Invalid ID or Password";
                          return View();
                      }

                    */

                }
                catch (Exception)
                {
                    return View();
                }
            }
            else
                return View();
        }
     

Thursday, 11 June 2015

Bind dropdown MVC

<div class="form-group">
                                        <label for="exampleInputEmail1">User Name</label>
                                        <input list="stat" name="user_name" class="form-control" required />
                                        <datalist id="stat">
                                            @foreach (var cell in ViewBag.user)
                                            {
                                                <option>@cell</option>
                                            }
                                        </datalist>
                                    </div>


Controller


public ActionResult addHolidayPack()
        {
             if (Session["User_Name"] != null)
             {
            try
            {              
                string s = null;
                DataTable dt = new DataTable();
                string str = "select th_name from Theme_master";
                dt = con.GetdataTable(str);
                ArrayList lis = new ArrayList();
                int n = dt.Rows.Count;
                for (int j = 0; j < n; j++)
                {
                    s = dt.Rows[j]["th_name"].ToString();
                    lis.Add(s);
                }
                ViewBag.theme = lis;


                string s1 = null;
                DataTable dt1 = new DataTable();
                string str1 = "select PK_name from Pack_Type";
                dt1 = con.GetdataTable(str1);
                ArrayList lis1 = new ArrayList();
                int n1 = dt1.Rows.Count;
                for (int j = 0; j < n1; j++)
                {
                    s1 = dt1.Rows[j]["PK_name"].ToString();
                    lis1.Add(s1);
                }
                ViewBag.pack = lis1;

                string s3 = null;
                DataTable dt3 = new DataTable();
                string str3 = "select U_Name from User_Master where U_Type='V'";
                dt3 = con.GetdataTable(str3);
                ArrayList lis3 = new ArrayList();
                int n3 = dt3.Rows.Count;
                for (int j = 0; j < n3; j++)
                {
                    s3 = dt3.Rows[j]["U_Name"].ToString();
                    lis3.Add(s3);
                }
                ViewBag.user = lis3;

                return View();
            }
            catch
            {
                return View();
            }
            }
           else
            {
                return RedirectToAction("Login", "Cp");
            }
        }

Validation in Asp.net MVC

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
using System.Web.Mvc;

namespace Book_Package.Models
{
    public class SignUp
    {
        [Required(ErrorMessage = "Please Enter Valid Name")]
        [Display(Name = "firstname")]
        [MinLength(2)]
        public string firstname { get; set; }
        public string lastname { get; set; }
        [Display(Name = "mobile(Mobile)")]
        [StringLength(10, ErrorMessage = "The Mobile must contains 10 characters", MinimumLength = 10)]
        public string mobile { get; set; }
        [Required(ErrorMessage = "Please Enter Valid Email Address")]
        [Display(Name = "email(Email Address)")]
        [RegularExpression(".+@.+\\..+", ErrorMessage = "Please Enter Correct Email Address")]
        public string email { get; set; }
        [Required(ErrorMessage = "Please Enter Password")]
        [StringLength(50, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)]
        [DataType(DataType.Password)]
        [Display(Name = "password")]
        public string password { get; set; }
        [Required(ErrorMessage = "Please Enter Confirm Password")]
         [StringLength(50, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)]
         [DataType(DataType.Password)]
         [Display(Name = "confirmpassword")]
         [Compare("password", ErrorMessage = "The password and confirmation password do not match.")]
        public string confirmpassword { get; set; }
    }
}

Admin Controller

Admin Controller:-


using GsMentors.Models;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Data.Entity;
using System.IO;

namespace GsMentors.Controllers
{
    public class AdminController : Controller
    {
        //
        // GET: /Admin/
        private gs_dbEntities con = new gs_dbEntities();
        public ActionResult Index()
        {
            if (Session["userid"] != null)
                return View();
            else
                return RedirectToAction("Login", "Admin");
        }
        public ActionResult Login()
        {
            return View();
        }
        [HttpPost]
        public ActionResult Login(LoginModel  call)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    if (!string.IsNullOrEmpty(call.UserName.ToString()) && !(string.IsNullOrEmpty(call.Password.ToString())))
                    {

                        var i = from o in con.User_Master where o.U_Name.Equals(call.UserName) && o.U_Password.Equals(call.Password) select o;
                        if (i.ToList().Count() > 0)
                        {
                            Session["userid"] = call.UserName.ToString();
                            return RedirectToAction("Index", "Admin");
                        }
                        else
                        {
                            ViewBag.err = "Invalid ID or Password!";
                            return View();
                        }
                    }
                    return View();
                }
                else
                    return View();
            }
            catch (Exception)
            {
                return View();
            }
        }

        public ActionResult Category()
        {
            var data = con.Category_Master.ToList();
            return View(data);
        }
      
        public ActionResult Comments()
        {
            return View();
        }
        
        public ActionResult addCat()
        {
            return View();
        }

        [HttpPost]
        public ActionResult addCat(Category_Master model)
        {
            if(ModelState.IsValid)
            {
                con.Category_Master.Add(model);
                con.SaveChanges();
                return RedirectToAction("Category");
            }           
            return View();
        }
        public ActionResult EditCat(int id=0)
        {
            Category_Master data = con.Category_Master.Find(id);
            if(data==null)
            {
                return HttpNotFound();
            }
            return View(data);
        }

        [HttpPost]
        public ActionResult EditCat(Category_Master model)
        {
            if(ModelState.IsValid)
            {
                con.Entry(model).State = EntityState.Modified;
                con.SaveChanges();
                return RedirectToAction("Category");
            }
            return View(model);
        }
        public ActionResult DeleteCat(int id=0)
        {
            Category_Master data = con.Category_Master.Find(id);
            if(data==null)
            {
                return HttpNotFound();
            }
            con.Category_Master.Remove(data);
            con.SaveChanges();
            return RedirectToAction("Category");
        }

        //Blogs goes here...
        public ActionResult Post()
        {
            var data = con.Blog_Master.Include(x => x.User_Master).Include(x => x.Category_Master);
            return View(data.ToList());
        }
        public ActionResult addPost()
        {
            ViewBag.User_ID = new SelectList(con.User_Master, "ID", "U_Name");
            ViewBag.Cat_ID = new SelectList(con.Category_Master, "ID", "Name");
            return View();
        }
        [HttpPost]
        public ActionResult addPost(Blog_Master data,IEnumerable<HttpPostedFileBase> image)
        {            
            if(ModelState.IsValid)
            {
                foreach (HttpPostedFileBase file in image)
                {
                    string cat_id = null;
                    if (file != null)
                    {
                        int max = 0;
                        int len = file.FileName.Length;
                        int startlen = len - 4;
                        string strlen = file.FileName.Substring(startlen);
                        var val=con.Blog_Master.FirstOrDefault(x=>x.ID.Equals(1));
                        if (val== null)
                        {
                            max = 0;
                        }
                        else
                        {

                            max = con.Blog_Master.Max(s => s.ID);
                        }
                                           
                        max++;
                        cat_id = "Blog" + "_" + max + strlen;
                        var path = Path.Combine(Server.MapPath("~/Image"), cat_id);
                        file.SaveAs(path);
                    }
                    Blog_Master obj = new Blog_Master();
                    obj.Cat_ID = data.Cat_ID;
                    obj.User_id = data.User_id;
                    obj.Title = data.Title;
                    obj.Tags = data.Tags;
                    obj.Pic = cat_id;
                    obj.Descr = data.Descr;
                    obj.Date = DateTime.Now.ToString();

                    con.Blog_Master.Add(obj);
                    con.SaveChanges();
                    return RedirectToAction("Post");
                }
            }
            ViewBag.User_ID = new SelectList(con.User_Master, "ID", "U_Name");
            ViewBag.Cat_ID = new SelectList(con.Category_Master, "ID", "Name");
            return View(data);
        }
        public ActionResult EditPost(int id=0)
        {
            Blog_Master data = con.Blog_Master.Find(id);
            if (data == null)
            {
                return HttpNotFound();
            }
            ViewBag.User_ID = new SelectList(con.User_Master, "ID", "U_Name");
            ViewBag.Cat_ID = new SelectList(con.Category_Master, "ID", "Name");
            return View(data);
        }
        [HttpPost]
        public ActionResult EditPost(Blog_Master data,IEnumerable<HttpPostedFileBase> image)
        {
            if (ModelState.IsValid)
            {
                foreach (HttpPostedFileBase file in image)
                {
                    string cat_id = null;
                    if (file != null)
                    {
                        int len = file.FileName.Length;
                        int startlen = len - 4;
                        string strlen = file.FileName.Substring(startlen);

                        cat_id = "Blog" + "_" + data.ID + strlen;
                        var path = Path.Combine(Server.MapPath("~/Image"), cat_id);
                        file.SaveAs(path);
                    }
                    Blog_Master obj = new Blog_Master();
                    obj.ID = data.ID;
                    obj.Cat_ID = data.Cat_ID;
                    obj.User_id = data.User_id;
                    obj.Title = data.Title;
                    obj.Tags = data.Tags;
                    obj.Pic = cat_id;
                    obj.Descr = data.Descr;
                    obj.Date = DateTime.Now.ToString();
                                     
                    con.Entry(obj).State = EntityState.Modified;
                    con.SaveChanges();
                    return RedirectToAction("Post");
                }
            }
            ViewBag.User_ID = new SelectList(con.User_Master, "ID", "U_Name");
            ViewBag.Cat_ID = new SelectList(con.Category_Master, "ID", "Name");
            return View(data);
        }
        public ActionResult DeletePost(int id=0)
        {
            Blog_Master data = con.Blog_Master.Find(id);
            if (data == null)
            {
                return HttpNotFound();
            }
            con.Blog_Master.Remove(data);
            con.SaveChanges();
            return RedirectToAction("Post");
        }
        public ActionResult Logout()
        {
            Session.Abandon();
            return RedirectToAction("Login", "Admin");
        }
    }
}

ViewData in MVC

View:-


@model IEnumerable<GsMentors.Models.Blog_Master>

@{
    Layout = "~/Views/Shared/_masterLayouth.cshtml";
}
@{

    IEnumerable<GsMentors.Models.Blog_Master> recent = ViewData["recent"] as IEnumerable<GsMentors.Models.Blog_Master>;
    IEnumerable<GsMentors.Models.Category_Master> cat = ViewData["cat"] as IEnumerable<GsMentors.Models.Category_Master>;
}

@*@section sl_image
{
    <img src="../../image1/header.jpg" />
}*@

<div class="container">
    <div class="row" style="float:left">




        @foreach (var item in Model)
        {
            <div class="col-md-1 date">
                <p><strong>@Html.DisplayFor(x => item.Date)</strong></p>
            </div>
            <div class="col-md-6">
                <h3>
                    <a href="/Blogs/Index/@item.ID" style="text-decoration:none;">
                        @Html.DisplayFor(x => item.Title)
                    </a>
                </h3>
                <p>
                    <a href="#"><span class="glyphicon glyphicon-user"></span>@Html.DisplayFor(x => item.User_Master.U_FirstName)@Html.DisplayFor(x => item.User_Master.U_LastName)</a>
                    <a href="#"><span class="glyphicon glyphicon-lock"></span>@Html.DisplayFor(x => item.Category_Master.Name)</a>&nbsp;
                    <a href="#"><span class="glyphicon glyphicon-tag"></span>@Html.DisplayFor(x => item.Tags)</a>&nbsp;
                    <a href="#"><span class="glyphicon glyphicon-cloud"></span>Leave a comment</a>
                </p>
                <p>
                    @Html.DisplayFor(x => item.Descr)
                </p>

            </div>
            <br />
        }

    </div>

    <div class="col-md-3 side" style="float: right;   margin-top: -191px;margin-right: 123px;">
        <h4><a href="#">Like our Facebook Page<a></h4>
        <hr>

        <h4>Recent Posts</h4>
        <hr>
        <ul>
            @foreach (GsMentors.Models.Blog_Master i in recent)
            {
                <li><a href="/Blogs/index/@i.ID">@i.Title</a></li>
            }
        </ul>
        <h4>Archives</h4>
        <hr>
        <ul>
            <li><a href="#">August 2011</a></li>
            <li><a href="#">July 2011</a></li>
        </ul>
        <h4>E-mail Subscription</h4>
        <p>Enter your email address to subscribe to this blog and receive notifications of new posts by email.</p>
        <p>Join 1 other follower</p>
        <input type="text" class="form-control" placeholder="Enter Your email address">
        <br>
        <a href="#" class="btn btn-primary">Sign me up!</a>
        <h4>Categories</h4>
        <ul>
            @foreach (GsMentors.Models.Category_Master i in cat)
            {
                <li><a href="/Blogs/Category/@i.ID">@i.Name</a></li>
            }
        </ul>
    </div>


</div>


Controller:-


    public ActionResult Index()
        {
            var data = db.Blog_Master.ToList();


            ViewData["recent"] = (from s in db.Blog_Master orderby s.Date select s).Take(5);
            ViewData["cat"] = (from s in db.Category_Master orderby s.Name select s);
            return View(data);
        }
            


Model:-


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;

namespace GsMentors.Models
{
    public class Query
    {

        [Required(ErrorMessage = "Please Enter Valid Username")]
        [Display(Name = "Name")]
        [MinLength(2)]
        public string Name { get; set; }
        [Required]
        [DataType(DataType.EmailAddress)]
        [RegularExpression(@"^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}" +
                           @"\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\" +
                           @".)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$",
                           ErrorMessage = "Email is not valid")]
        public string Email { get; set; }
        [Required]
        [DataType(DataType.PhoneNumber)]
        public int Mobile { get; set; }
        [Required]
       
        public int Website { get; set; }
        [Required]
        public string quary { get; set; }
    }
}

Thursday, 4 June 2015

Linq Query


The SELECT Operation
private void GetCourses()
{
      
//create DataContext object      OperationDataContext OdContext = new OperationDataContext();
      var courseTable = from course in OdContext.GetTable<COURSE>() select course;
      
//grdCourse is gridview id      grdCourse.DataSource = courseTable;
      grdCourse.DataBind();
}


The INSERT Operation
private void AddNewCourse()
{
      
//Data maping object to our database      OperationDataContext OdContext = new OperationDataContext();
      COURSE objCourse = new COURSE();
      objCourse.course_name = "B.Tech";
      objCourse.course_desc = "Bachelor Of Technology";
      objCourse.modified_date = DateTime.Now;
      
//Adds an entity in a pending insert state to this System.Data.Linq.Table<TEntity>and parameter is the entity which to be added      OdContext.COURSEs.InsertOnSubmit(objCourse);
      
// executes the appropriate commands to implement the changes to the database      OdContext.SubmitChanges();
}

The Update Operation
private void UpdateCourse()
{
      OperationDataContext OdContext = new OperationDataContext();
      
//Get Single course which need to update      COURSE objCourse = OdContext.COURSEs.Single(course => course.course_name == "B.Tech");
      
//Field which will be update      objCourse.course_desc = "Bachelor of Technology";
      
// executes the appropriate commands to implement the changes to the database      OdContext.SubmitChanges();
 }


The DELETE Operation
private void DeleteCourse()
{
      OperationDataContext OdContext = new OperationDataContext();
      
//Get Single course which need to Delete      COURSE objCourse = OdContext.COURSEs.Single(course => course.course_name == "B.Tech");
      
//Puts an entity from this table into a pending delete state and parameter is the entity which to be deleted.      OdContext.COURSEs.DeleteOnSubmit(objCourse);
      
// executes the appropriate commands to implement the changes to the database      OdContext.SubmitChanges();
}


Conculsion
To perform select, insert, update and delete operations we create a table and create a data context class; in other words a dbml file. In this file designer view we drag and drop the COURSE table from the Server Explorer. This data context class is an Object and table mapping and we perform the operation on the object and database updated according to the action using the submitChanges() method.

Rownumber function in SQL


SELECT * FROM (SELECT * , ROW_NUMBER() OVER (ORDER BY age) as Rn FROM test ) t
WHERE Rn=4

Sunday, 17 May 2015

Difference between MVC3, MVC4,MVC5

MVC3 Vs MVC4 Vs MVC5

ASP.NET MVC3

  • New Project Templates having support for HTML 5 andCSS 3.
  • Improved Model validation.
  • Razor View Engine introduced with a bundle of new features.
  • Having support for Multiple View Engines i.e. Web Forms view engine, Razor or open source. You can follow here for a detailed comparison on difference betweenWebForm View Engine and Razor View Engine.
  • Controller improvements like ViewBag dynamic property and ActionResults Types etc. Dynamic property is a new feature introduced in C# 4.0. ViewBag being a dynamic property has an advantage over ViewData that it doesn’t require checking NULL values. For detailed difference between ViewBag and ViewData can be foundhere.

  • Unobtrusive JavaScript approach that actually separates the functionality from presentation layer on a web page.
  • Improved Dependency Injection with new IDependencyResolver.
  • Partial page output caching.

ASP.NET MVC 4

  • ASP.NET Web API, a framework that simplifies the creation of HTTP services and serving a wide range of clients. Follow to create your first ASP.NET Web API service.
  • Adaptive rendering and other look-n-feel improvements to Default Project Templates.
  • A truly Empty Project Template.
  • Based on jQuery Mobile, new Mobile Project Template introduced.
  • Support for adding controller to other project folders also.
  • Task Support for Asynchronous Controllers.
  • Controlling Bundling and Minification through web.config.
  • Support for OAuth and OpenID logins using DotNetOpenAuth library.
  • Support for Windows Azure SDK 1.6 and new releases.

ASP.NET MVC5

  • ASP.NET Identity for authentication and identity management. Thesedays, modern applications are developed for broader range of clients such as web, mobile in mind. Also, users are actively using their social identities from various social channels like facebook, youtube, twitter etc. ASP.NET Identity is a new Membership system to handle authentication and authorization for variety of clients as well as using user’s existing social identities.
  • Authentication Filters for authenticating user by custom or third-party authentication provider.
  • With the help of Filter overrides, we can now override filters on a method or controller.
  • Bootstrap replaced the default MVC template.
  • Attribute Routing is now integrated into MVC5. Basically, MVC Routing is an excellent way to create human friendly and Search Engine Optimized URLs. You can easily get understanding about Routing in ASP.NET MVC here. Attribute based routing enables us to define routes along with action methods as follows:

Monday, 4 May 2015

Top 10 Changes in ASP.NET 5 and MVC 6

Top 10 Changes in ASP.NET 5 and MVC 6

Update on April, 30 2015

When I wrote this blog post, I wrote that Microsoft was not planning to support VB.NET in ASP.NET 5/MVC 6. That was true when I wrote the blog post, but this blog post generated some strong reactions from the VB.NET community. Well, it looks like VB.NET is back!
I spent the last couple of weeks writing sample code for ASP.NET 5/MVC 6 and I was surprised by the depth of the changes in the current beta release of ASP.NET 5. ASP.NET 5 is the most significant new release of ASP.NET in the history of the ASP.NET framework — it has been rewritten from the ground up.
In this blog post, I list what I consider to be the top 10 most significant changes in ASP.NET 5. This is a highly opinionated list. If other changes strike you as more significant, please describe the change in a comment.

1. ASP.NET on OSX and Linux

Linux and OSX
For the first time in the history of ASP.NET, you can run ASP.NET 5 applications on OSX and Linux. Let me repeat this. ASP.NET 5 apps can run on Windows, OSX, and Linux. This fact opens up ASP.NET to a whole new audience of developers and designers.
The traditional audience for ASP.NET is professional developers working in a corporation. Corporate customers are welded to their Windows machines.
Startups, in stark contrast, tend to use OSX/Linux. Whenever I attend a startup conference, the only machines that I see in the audience are Macbook Pros. These people are not the traditional users of ASP.NET.
Furthermore, designers and front-end developers – at least when they are outside the corporate prison – also tend to use Macbook Pros. Whenever I attend a jQuery conference, I see Macbook Pros everywhere (the following picture is from the jQuery blog).
jQuery Conference
Enabling ASP.NET 5 to run on Windows, OSX, and Linux changes everything. For the first time, all developers and designers can start building apps with ASP.NET 5. And, they can use their favorite development environments such as Sublime Text and WebStorm when working with ASP.NET apps (No Visual Studio required).
Take a look at the OmniSharp project to see how you can use editors such as Sublime Text, Atom, Emacs, and Brackets with ASP.NET 5:

2. No More Web Forms

ASP.NET Unleashed
I love ASP.NET Web Forms. I’ve spent hundreds – if not thousands – of hours of my life building Web Forms applications. However, it is finally time to say goodbye. ASP.NET Web Forms is not part of ASP.NET 5.
You can continue to build Web Forms apps in Visual Studio 2015 by targeting the .NET 4.6 framework. However, Web Forms apps cannot take advantage of any of the cool new features of ASP.NET 5 described in this list. If you don’t want to be left behind as history marches forward then it is finally time for you to rewrite your Web Forms app into ASP.NET MVC.

3. No More Visual Basic

Visual Basic
It is also time to say goodbye to Visual Basic. ASP.NET 5 only supports C# and Visual Basic is left behind.
My hope is that this change won’t be too painful. I believe that there are only two people in the entire world who are building MVC apps in Visual Basic. It is time for both of you to stop it. There are good automatic converters for going from Visual Basic to C#:

4. Tag Helpers

Tag Helpers is the one feature that might have the biggest impact on the way that you create your views in an ASP.NET MVC application. Tag Helpers are a better alternative to using traditional MVC helpers.
Consider the following MVC view that contains a form for creating a new product:
1
2
3
4
5
6
7
8
9
10
11
@model MyProject.Models.Product
 
 
@using (Html.BeginForm())
{
    <div>
        @Html.LabelFor(m => p.Name, "Name:")
        @Html.TextBoxFor(m => p.Name)
    </div>
    <input type="submit" value="Create" />
}
In the view above, the Html.BeginForm(), Html.LabelFor(), and Html.TextBoxFor() helpers are used to create the form. These helpers would not be familiar to an HTML designer.
Here’s how the exact same form can be created by using Tag Helpers:
1
2
3
4
5
6
7
8
9
10
11
@model MyProject.Models.Product
@addtaghelper "Microsoft.AspNet.Mvc.TagHelpers"
 
<form asp-controller="Products" asp-action="Create" method="post">
    <div>
        <label asp-for="Name">Name:</label>
        <input asp-for="Name" />
    </div>
 
    <input type="submit" value="Save" />
</form>
Notice that this new version of the form contains only (what looks like) HTML elements. For example, the form contains an INPUT element instead of an Html.TextBoxFor() helper. A front-end designer would be fine with this page.
The only thing special about this view is the special asp-for attributes. These attributes are used to extend the elements with server-side ASP.NET MVC functionality.
Damien Edwards put together an entire sample site that uses nothing but Tag Helpers here:

5. View Components

Goodbye subcontrollers and hello View Components!
In previous versions of ASP.NET MVC, you used the Html.Action() helper to invoke a subcontroller. For example, imagine that you want to display banner ads in multiple views. In that case, you would create a subcontroller that contained the logic for returning a particular banner advertisement and call the subcontroller by invoking Html.Action() from a view.
Subcontrollers – the Html.Action() helper — are not included in the current beta of MVC 6. Instead, MVC 6 includes an alternative technology called View Components.
Here’s how you can create a View Component that displays one of two banner advertisements depending on the time of day:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
using Microsoft.AspNet.Mvc;
using System;
 
namespace Partials.Components
{
    public class BannerAd : ViewComponent
    {
        public IViewComponentResult Invoke()
        {
            var adText = "Buy more coffee!";
 
            if (DateTime.Now.Hour > 18)
            {
                adText = "Buy more warm milk!";
            }
            return View("_Advertisement", adText);
        }
    }
}
If the time is before 5:00pm then the View Component returns a partial named _Advertisement with the advertisement text “Buy more coffee!”. If the time is after 5:00pm then the text changes to “Buy more warm milk!”.
Here’s what the _Advertisement partial looks like:
1
2
3
4
5
@model string
 
<div style="border:2px solid green;padding:15px">
    @Model
</div>
Finally, here is how you can use the BannerAd View Component in an MVC view:
1
@Component.Invoke("BannerAd")
View Components are very similar to subcontrollers. However, subcontrollers were always a little odd. They were pretending to be controller actions but they were not really controller actions. View Components just seem more natural.

6. GruntJS, NPM, and Bower Support

GruntJS
Front-end development gets a lot of love in ASP.NET 5 through its support for GruntJS (and eventually Gulp).
GruntJS is a task runner that enables you to build front-end resources such as JavaScript and CSS files. For example, you can use GruntJS to concatenate and minify your JavaScript files whenever you perform a build in Visual Studio.
There are thousands of GruntJS plugins that enable you to do an amazing variety of different tasks (there are currently 4,334 plugins listed in the GruntJS plugin repository):
For example, there are plugins for running JavaScript unit tests, for validating the code quality of your JavaScript (jshint), compiling LESS and Sass files into CSS, compiling TypeScript into JavaScript, and minifying images.
In order to support GruntJS, Microsoft needed to support two new package managers (beyond NuGet). First, because GruntJS plugins are distributed as NPM packages, Microsoft added support for NPM packages.
Second, because many client-side resources – such as Twitter Bootstrap, jQuery, Polymer, and AngularJS – are distributed through Bower, Microsoft added support for Bower.
This means that you can run GruntJS using plugins from NPM and client resources from Bower.

7. Unified MVC and Web API Controllers

In previous versions of ASP.NET MVC, MVC controllers were different than Web API controllers. An MVC controller used the System.Web.MVC.Controller base class and a Web API controller used the System.Web.Http.ApiController base class.
In MVC 6, there is one and only one Controller class that is the base class for both MVC and Web API controllers. There is only the Microsoft.AspNet.Mvc.Controller class.
MVC 6 controllers return an IActionResult. When used as an MVC controller, the IActionResult might be a view. When used as a Web API controller, the IActionResult might be data (such as a list of products). The same controller might have actions that return both views and data.
In MVC 6, both MVC controllers and Web API controllers use the same routes. You can use either convention-based routes or attribute routes and they apply to all controllers in a project.

8. AngularJS

AngularJS is one of the most popular client-side frameworks for building Single Page Applications (SPAs). Visual Studio 2015 includes templates for creating AngularJS modules, controllers, directives, and factories.
AngularJS
The support in ASP.NET 5 for GruntJS makes ASP.NET an excellent server-side framework for building client-side AngularJS apps. You can combine and minify all of your AngularJS files automatically whenever you perform a build. You can interact with an MVC 6 controller from an AngularJS $resource using REST.

9. ASP.NET Dependency Injection Framework

ASP.NET 5 has built-in support for Dependency Injection and the Service Locator pattern. This means that you no longer need to rely on third-party Dependency Injection frameworks such as Ninject or AutoFac.
Imagine, for example, that you have created an IRepository interface and an EFRepository class that implements that interface. In that case, you can bind the EFRepository class to the IRepository interface in the ConfigureServices() method of the Startup.cs class like this:
1
services.AddTransient<IRepository, EFRepository>();
After you bind EFRepository and IRepository then you can use constructor dependency injection in your MVC controllers (and any other class) using code like this:
1
2
3
4
5
6
7
8
9
public class ProductsController : Controller
{
    private IRepository _repo;
 
    public ProductsController(IRepository repo)
    {
        _repo = repo;
    }
}
In the code above, the IRepository interface is passed to the constructor for the ProductsController. The built-in ASP.NET Dependency Injection framework passes EFRepository to the ProductsController because IRepository was bound to EFRepository.
You also can use the Service Locator pattern. Wherever you can access the HttpContext, you can access any registered services. For example, you can retrieve the EFRepository by using the following code inside of an MVC controller action:
1
var repo = this.Context.ApplicationServices.GetRequiredService<IRepository>();

10. xUnit.net

Goodbye Visual Studio Unit Testing Framework and hello xUnit.net!
In previous versions of ASP.NET MVC, the default testing framework was the Visual Studio Unit Testing Framework (sometimes called mstest). This framework uses the [TestClass] and [TestMethod] attributes to describe a unit test:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
[TestClass]
public class CalculatorTests {
 
    [TestMethod]
    public void TestAddNumbers() {
        // Arrange
        var calc = new Calculator();
 
        // Act
        var result = calc.AddNumbers(0, 0);
 
        // Assert
        Assert.AreEqual(0, result);
 
    }
 
}
ASP.NET 5 uses xUnit.net as its unit test framework. This framework uses the [Fact] attribute instead of the [TestMethod] attribute (and no [TestClass] attribute]):
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
public class CalculatorTests
{
    [Fact]
    public void AddNumbers()
    {
        // Arrange
        var calculator = new Calculator();
 
        // Act
        var result = calculator.AddNumbers(1, 1);
 
        // Assert
        Assert.Equal(result, 13);
    }
}
If you look at the source code for ASP.NET 5 then you’ll see that xUnit.net is used to test ASP.NET extensively. For example, the MVC repository contains unit tests written with xUnit.net. You can take a look at the MVC repository (and its unit tests) here:
ASP.NET uses a fork of xUnit.net that is located here: