Thursday 22 December 2016

How to deploy asp.net web application

install iis
https://www.microsoft.com/en-ca/download/details.aspx?id=48264

Control Panel\Programs\Programs and Features -> turn windows features on or off


Control Panel\System and Security\Administrative Tools -> internet information service manager

Application Pools -> add application pools

right click newly created .net test application pool  -> advanced setting -> change identity to local system.


open SQL Server Management Studio -> database -> my database -> security -> right click user -> new user -> gerneral ->change user name, log in name




membership -> select datareader, datawritter


run visual as administrator -> create wcf service project


//iserverce1.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;

namespace service_1
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IService1" in both code and config file together.
    [ServiceContract]
    public interface IService1
    {

        [OperationContract]
        List<dto> GetData();

     
    }
}

------------------------------------------------------------
//service1.svc

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;

namespace service_1
{
    public class Service1 : IService1
    {
        public List<dto> GetData()
        {
            var db = new CTTIEntities();

            var data = db.Instructors.Select(x => new dto
            {
                FirstName = x.FirstName,
                LastName = x.LastName,
                Id = x.Id
            }).ToList();

            return data;
        }
    }
}

--------------------------------------------------------
//dto.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Web;

namespace service_1
{
    [DataContract]
    public class dto
    {
        [DataMember]
        public int Id { get; set; }
        [DataMember]
        public string FirstName { get; set; }
        [DataMember]
        public string LastName { get; set; }
    }
}

-------------------------------------------------------------

build application -> right click on project -> publish -> profile -> custom -> enter any name



connection -> web deploy

setting -> browse database -> publish

close visual studio -> open iis manager -> right click on newly created service_2 -> advanced setting

change application pool to newly created .net test

click browse on the right side

click service1.svc

click top link, should see the service method

run ipconfig in command window to get ip address for current computer/server -> 192.168.1.74

on second computer/cloud type 192.168.1.74/service_2/Service1.svc on internet exployer
should see the same service page

on second computer run visual studio as administrator -> create web project

right click on reference -> add service reference -> type in service address -> go -> iservice1

on default.aspx configer objectdatasouce 

select method

run application, should see table displayed

right click on project -> publish

on iis manager, should see the web deployment

run ipconfig -> second computer ip -> 192.168.1.70

on third computer/client type 192.168.1.70/instructor on internet explorer 


server -> cloud -> client


reference:
https://www.youtube.com/watch?v=88YtB6U9NrY
https://www.asp.net/mvc/overview/deployment/visual-studio-web-deployment/deploying-to-iis
https://www.youtube.com/watch?v=18-zatWd68s
http://stackoverflow.com/questions/4388066/the-page-you-are-requesting-cannot-be-served-because-of-the-extension-configura

No comments:

Post a Comment