Saturday, September 27, 2014

ASP.NET MVC3 Creating New Project

---
ASP.NET MVC3 Creating New Project

1) Start
2) Creating Your First Application
2-2) Project Settings
2-3) Default Project Template Files
3) Debugging Project

1) Start

1-1a) Start by running Visual Web Developer 2010 Express ("Visual Web Developer" for short) and select New Project from the Start page.
or
1-1b)  Use the menu and select File > New Project.

2) Creating Your First Application

2-1) You can create applications using either Visual Basic or Visual C# as the programming language. Select Visual C# on the left and then select ASP.NET MVC 3 Web Application. Name your project "MvcMovie" and then click OK.

2-2) Project Settings

In the New ASP.NET MVC 3 Project dialog box, select Internet Application. Check Use HTML5 markup and leave Razor as the default view engine.
Click OK.

2-3) Default Project Template Files

Visual Web Developer used a default template for the ASP.NET MVC project you just created, so you have a working application right now without doing anything! This is a simple "Hello World!" project, and it's a good place to start your application.

3) Debugging Project

3-1) From the Debug menu, select Start Debugging.
3-2) Notice that the keyboard shortcut to start debugging is F5.
F5 causes Visual Web Developer to start a development web server and run your web application. Visual Web Developer then launches a browser and opens the application's home page. Notice that the address bar of the browser says localhost and not something like example.com. That's becauselocalhost always points to your own local computer, which in this case is running the application you just built. When Visual Web Developer runs a web project, a random port is used for the web server. In the image below, the random port number is 43246. When you run the application, you'll probably see a different port number.
3-3) Outcome:
---

Thursday, September 25, 2014

How To Install SQL Server Management Studio

---
How To Install SQL Server Management Studio

1) Run SQL Server Management Studio

2) Follow screenshots

Select “New SQL Server stand-alone installation or add features to an existing installation”. It will then run a rule check. Make sure there are no failures and then click OK.

image
Click OK
image
Click Install.
image
Click Next
image
Select Perform a new installation of SQL Server 2008.
image
Click Next
image
Click Next
image
Click Next
image
Click Next
image
Click Next
image
Click Next
image
Click Install
image
Click Next
image
Click Close
image
---

Publishing MVC 4 Projects To Web Server

---
Publishing MVC 4 Projects To Web Server

1) Download Sample Project Website

Download the Sample Code

2) Unzip to your projects folder.

3) Run Visual Studio 2010 and open the project.

4) Check connection strings in Web.config file

Initial codes…
<connectionStrings>
    <add name="DefaultConnection" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=aspnet-MvcMovie-20120730162622;Integrated Security=SSPI" providerName="System.Data.SqlClient" />
    <add name="MovieDBContext" connectionString="Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\Movies.mdf;Integrated Security=True"
   providerName="System.Data.SqlClient" />
  </connectionStrings>
Change to … (Copy connectionString for DefaultConnection, paste to MovieDBContext and rename the Initial Catalog to Movies)
<connectionStrings>
    <add name="DefaultConnection" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=aspnet-MvcMovie-20120730162622;Integrated Security=SSPI" providerName="System.Data.SqlClient" />
    <add name="MovieDBContext"   connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=aspnet-MvcMovie-20120730162622;Integrated Security=SSPI" providerName="System.Data.SqlClient" />
  </connectionStrings>

5) Run the project

6) Register

Username: user1
Password: password123!

7) Stop Project Execution

8) Publish to your Web Server

---

Using UltiDev to run ASP NET MVC 4 Websites

---
Using UltiDev to run ASP NET MVC 4 Websites

1) Download Ultidev and run the setup

https://lh6.googleusercontent.com/OIEgiEksixCJgYw6TxDpKRfH8-0FRJTEuhfXPHXlFfJhEoF6SXQDFn6kBHL6akl8ZyG9kPKpP8ccTyX1R-QlpfiW-MfhSdbbwSL2up1WoeiOUHsdKsR3FWaTDiltm5Swp9iefl1WVhk

2) Create a folder for Web Publishing

Eg C:\Websites\MvcMovie

3) Run UltiDev

3-1) Click Register Button.
3-2) Follow the screenshots
---

ASP NET MVC 4 Controller View and ViewBag

---
ASP.NET MVC 4 Controller, View and ViewBag
Controller - Controls application logic
Views - Outputs messages to user
ViewBag - Dynamic Storage Object shared between Controller and View 


~\Controllers\HomeController.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace MVC4b.Controllers
{
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            ViewBag.Message = "Modify this template to jump-start your ASP.NET MVC application.";
            return View();
        }
        public ActionResult About()
        {
            ViewBag.Message = "Your app description page.";
            return View();
        }
        public ActionResult Contact()
        {
            ViewBag.Message = "Your contact page.";
            return View();
        }
    }
}
~\Views\Index.cshtml
@{
    ViewBag.Title = "Home Page";
}
@section featured {
    <section class="featured">
        <div class="content-wrapper">
            <hgroup class="title">
                <h1>@ViewBag.Title.</h1>
                <h2>@ViewBag.Message</h2>
            </hgroup>
            <p>
                To learn more about ASP.NET MVC visit
                <a href="http://asp.net/mvc" title="ASP.NET MVC Website">http://asp.net/mvc</a>.
                The page features <mark>videos, tutorials, and samples</mark> to help you get the most from ASP.NET MVC.
                If you have any questions about ASP.NET MVC visit
                <a href="http://forums.asp.net/1146.aspx/1?MVC" title="ASP.NET MVC Forum">our forums</a>.
            </p>
        </div>
    </section>
}
<h3>We suggest the following:</h3>
<ol class="round">
    <li class="one">
        <h5>Getting Started</h5>
        ASP.NET MVC gives you a powerful, patterns-based way to build dynamic websites that
        enables a clean separation of concerns and that gives you full control over markup
        for enjoyable, agile development. ASP.NET MVC includes many features that enable
        fast, TDD-friendly development for creating sophisticated applications that use
        the latest web standards.
        <a href="http://go.microsoft.com/fwlink/?LinkId=245151">Learn more…</a>
    </li>
    <li class="two">
        <h5>Add NuGet packages and jump-start your coding</h5>
        NuGet makes it easy to install and update free libraries and tools.
        <a href="http://go.microsoft.com/fwlink/?LinkId=245153">Learn more…</a>
    </li>
    <li class="three">
        <h5>Find Web Hosting</h5>
        You can easily find a web hosting company that offers the right mix of features
        and price for your applications.
        <a href="http://go.microsoft.com/fwlink/?LinkId=245157">Learn more…</a>
    </li>
</ol>
---