ASP. Build a personal website (1) _ Environment

Source: Internet
Author: User
Tags mssqlserver server installation and configuration access database hosting net core windows server hosting server hosting sql server express connectionstrings

Read Catalogue

  • First, the deployment environment
    • 1.SQL Server Installation and configuration
    • 2. Server firewall configuration
    • 3. Testing the Remote Access database
    • 4. IIS environment and. NET Core Windows Server Hosting Configuration
  • Ii. creating an ASP. NET Core Web project
  • Iii. Publishing Web sites to servers

Related Resources

  • Online Demo
  • GitHub source
Welcome to my personal blog for a better reading experience and more sharing articles ~

The ASP. NET Core2.0 has been released for a while, which is a significant milestone for the. At present, the. NET core has an open source, cross-platform, flexible deployment, modular architecture and many other features, attracting a large number of developers. I also began to join the embrace. NET Core Army, then build a personal website!

First of all, this should be a long-term project, I will not regularly update, continuous integration, and slowly put the new features you want to overlay on the site. This is also the process of accumulation, I hope that through the article to share to Bo friends, but also welcome you to pay attention to me, with me to discuss together, and common progress!

Say no more, let's start

Back to the top deployment environment

Server environment

    • Operating system: Windows Server R2
    • Database: SQL Server 2012

Development environment

    • VS 2017

Here in order to build a public network can access the website, the server I use the XX cloud server (comes with Server 2008 system, provide public IP). Of course everyone just want to practice practiced hand don't want to spend money, also do not matter, local run debugging, some remote configuration content can skip directly.

With the server, we also need to build a database. Here I choose SQL Server Express Edition (with database management tools, about 700M), corresponding to small and medium-sized applications is enough. Mainly because the cloud server CPU, memory, disk is too precious, as much as possible, not the latest or most complete version.

SQL Server Installation and configuration

Run the SQL Server installation package, follow the prompts step by step installation, the default installation is to include the customer single SDK and management tools, after installation, SQL Server will automatically generate a DB instance; Open the menu in SQL Server Management Studio, Connect to the DB instance to see that the database is being accessed normally. Of course, there is no problem accessing the local database, but we need the extranet to access the database remotely, so we need to do some configuration:

1th Step, we select the DB instance, right----and select security

Because remote access cannot be authenticated only by Windows, here we check SQL Server and Windows Authentication mode;

2nd step, check the connection, confirm "Allow remote connection to this server" check;

3rd, DB instance--security--Login-->sa right-click Properties

Set the Super Administrator sa Password and enable the SA user;

5th step, exit first, then log in with SA, success means that SA account is enabled

6th step, we can close SQL Server Management Studio, open SQL Server Configuration Manager

Check the MSSQLSERVER protocol to change the TCP/IP protocol status to Enabled (default is disabled), after we restart SQL Server;

For TCP/IP properties, switch the Address tab to verify that the TCP port is 1433, if it is not, the following configuration:

At this point, the relevant configuration of SQL Server has been set up, but still cannot support remote access, we also need to set up a server firewall.

Server firewall configuration

Open the Server Manager, check the firewall configuration, there are "inbound rules", click to enter;

Check "new Rule ..."

Rule Type Select port:

Protocol select TCP protocol, port number input 1433 (SQL Server default port)

Next, select "Allow connection"

Next, rule configuration file, select All

Finally, enter the rule name, named "SQL Server Port", click Finish, you can see that our added rule has been allowed to access the firewall in the scope.

Testing the remote Access database

Open vs 2017 on Local machine, find View-Server Explorer-data connection, right---add connection;

Change the data source, select Microsoft SQL Server;

Server name, enter the IP address of the cloud server, select SQL Server Authentication, type the user name and password that you set earlier to load all the databases under the remote DB instance. So we don't even have a problem with the remote database.

IIS environment and. NET Core Windows Server Hosting Configuration

In order to run our web site on the server, you first need to configure IIS.

On Server 2008, add roles, select Web Server, and complete the IIS installation.

A typical. NET published Web site can now be configured to run, but. NET core is different from a traditional ASP. asp. Kestrel Server. Kestrel is a cross-platform web Server that, like IIS, is responsible for the listening, receiving, and responding of requests, but without IIS's rich management capabilities, IIS is still required to handle some of the predecessor work.

So this block we also need to install the reverse proxy for IIS to Kestrel server:. NET Core Windows Server Hosting Bundle

Once the installation is complete, the machine needs to be restarted, and then we can formally take the. NET Core website.

Back to top create an ASP. NET Core Web project

After the preparation is done, we can finally start building the project, open vs 2017, file-to-project, create ASP. NET Core Web project, click OK;

Here, the default choice is the. NET Core 2.0 environment, WEB application (Model View Controller), note that here's the authentication, I chose the individual user account, primarily for user and role management, and authentication. There is a separate section behind, specifically to discuss this piece of knowledge with you. When you're sure, VS automatically helps us generate the code for the project that works.

At this point, we are going to build the database table structure by connecting to the database on the remote server and by code first.

In the database instance first, create a database named Mywebsite:

In local vs, through the previous configuration of Server Explorer, we saw that we could connect to the Mywebsite database and test the connection successfully.

Click OK to establish a data connection, right-to-property, you can view the connection string, copy the connection string

Data source=180.*.*.89;initial Catalog=mywebsite; User Id=sa; password=***********

Open the project configuration file Appsettings.json:

Replace the default connection string with the following string:

  "ConnectionStrings": {    "defaultconnection": "Data source=180.*.*.89;initial catalog=mywebsite; User Id=sa; password=******* "  },

In this way, the database connection is configured. Because the individual authentication items are selected, VS helps us generate the corresponding entity classes and database migrations, all we have to do is update the database to generate the corresponding table structure.

Open Tool-->nuget Package Manager--Package Manager console

Enter Update-database and run, after success, we look back at the remote Mywebsite database, help us to automatically generate all the table structure

Next, we run the CTRL+F5, the website starts normally as follows:

Back to top publishing site to server

Website local Operation No problem, we continue to follow the release of the operation, the project right click, select "Publish ...", temporarily we select the Local folder (after the project management, we then configure the remote publishing), the post-release generated files copied to the cloud server, here in the C:\MyWebSite directory.

In IIS management, check the Web site and deactivate the default Web site, because it takes up 80 ports and conflicts with what we want to build;

Right-click Add Web Site

As configured, use 80 port, HTTP default access port.

Click OK, so our site so far, the successful construction!

Use the browser, enter the extranet IP address to access our cloud server (if not, please check if the firewall is open 80 port, as set before the line):

OK, perfect ~

---restore content ends---

Read Catalogue

  • First, the deployment environment
    • 1.SQL Server Installation and configuration
    • 2. Server firewall configuration
    • 3. Testing the Remote Access database
    • 4. IIS environment and. NET Core Windows Server Hosting Configuration
  • Ii. creating an ASP. NET Core Web project
  • Iii. Publishing Web sites to servers

Related Resources

  • Online Demo
  • GitHub source
Welcome to my personal blog for a better reading experience and more sharing articles ~

The ASP. NET Core2.0 has been released for a while, which is a significant milestone for the. At present, the. NET core has an open source, cross-platform, flexible deployment, modular architecture and many other features, attracting a large number of developers. I also began to join the embrace. NET Core Army, then build a personal website!

First of all, this should be a long-term project, I will not regularly update, continuous integration, and slowly put the new features you want to overlay on the site. This is also the process of accumulation, I hope that through the article to share to Bo friends, but also welcome you to pay attention to me, with me to discuss together, and common progress!

Say no more, let's start

Back to the top deployment environment

Server environment

    • Operating system: Windows Server R2
    • Database: SQL Server 2012

Development environment

    • VS 2017

Here in order to build a public network can access the website, the server I use the XX cloud server (comes with Server 2008 system, provide public IP). Of course everyone just want to practice practiced hand don't want to spend money, also do not matter, local run debugging, some remote configuration content can skip directly.

With the server, we also need to build a database. Here I choose SQL Server Express Edition (with database management tools, about 700M), corresponding to small and medium-sized applications is enough. Mainly because the cloud server CPU, memory, disk is too precious, as much as possible, not the latest or most complete version.

SQL Server Installation and configuration

Run the SQL Server installation package, follow the prompts step by step installation, the default installation is to include the customer single SDK and management tools, after installation, SQL Server will automatically generate a DB instance; Open the menu in SQL Server Management Studio, Connect to the DB instance to see that the database is being accessed normally. Of course, there is no problem accessing the local database, but we need the extranet to access the database remotely, so we need to do some configuration:

1th Step, we select the DB instance, right----and select security

Because remote access cannot be authenticated only by Windows, here we check SQL Server and Windows Authentication mode;

2nd step, check the connection, confirm "Allow remote connection to this server" check;

3rd, DB instance--security--Login-->sa right-click Properties

Set the Super Administrator sa Password and enable the SA user;

5th step, exit first, then log in with SA, success means that SA account is enabled

6th step, we can close SQL Server Management Studio, open SQL Server Configuration Manager

Check the MSSQLSERVER protocol to change the TCP/IP protocol status to Enabled (default is disabled), after we restart SQL Server;

For TCP/IP properties, switch the Address tab to verify that the TCP port is 1433, if it is not, the following configuration:

At this point, the relevant configuration of SQL Server has been set up, but still cannot support remote access, we also need to set up a server firewall.

Server firewall configuration

Open the Server Manager, check the firewall configuration, there are "inbound rules", click to enter;

Check "new Rule ..."

Rule Type Select port:

Protocol select TCP protocol, port number input 1433 (SQL Server default port)

Next, select "Allow connection"

Next, rule configuration file, select All

Finally, enter the rule name, named "SQL Server Port", click Finish, you can see that our added rule has been allowed to access the firewall in the scope.

Testing the remote Access database

Open vs 2017 on Local machine, find View-Server Explorer-data connection, right---add connection;

Change the data source, select Microsoft SQL Server;

Server name, enter the IP address of the cloud server, select SQL Server Authentication, type the user name and password that you set earlier to load all the databases under the remote DB instance. So we don't even have a problem with the remote database.

IIS environment and. NET Core Windows Server Hosting Configuration

In order to run our web site on the server, you first need to configure IIS.

On Server 2008, add roles, select Web Server, and complete the IIS installation.

A typical. NET published Web site can now be configured to run, but. NET core is different from a traditional ASP. asp. Kestrel Server. Kestrel is a cross-platform web Server that, like IIS, is responsible for the listening, receiving, and responding of requests, but without IIS's rich management capabilities, IIS is still required to handle some of the predecessor work.

So this block we also need to install the reverse proxy for IIS to Kestrel server:. NET Core Windows Server Hosting Bundle

Once the installation is complete, the machine needs to be restarted, and then we can formally take the. NET Core website.

Back to top create an ASP. NET Core Web project

After the preparation is done, we can finally start building the project, open vs 2017, file-to-project, create ASP. NET Core Web project, click OK;

Here, the default choice is the. NET Core 2.0 environment, WEB application (Model View Controller), note that here's the authentication, I chose the individual user account, primarily for user and role management, and authentication. There is a separate section behind, specifically to discuss this piece of knowledge with you. When you're sure, VS automatically helps us generate the code for the project that works.

At this point, we are going to build the database table structure by connecting to the database on the remote server and by code first.

In the database instance first, create a database named Mywebsite:

In local vs, through the previous configuration of Server Explorer, we saw that we could connect to the Mywebsite database and test the connection successfully.

Click OK to establish a data connection, right-to-property, you can view the connection string, copy the connection string

Data source=180.*.*.89;initial Catalog=mywebsite; User Id=sa; password=***********

Open the project configuration file Appsettings.json:

Replace the default connection string with the following string:

  "ConnectionStrings": {    "defaultconnection": "Data source=180.*.*.89;initial catalog=mywebsite; User Id=sa; password=******* "  },

In this way, the database connection is configured. Because the individual authentication items are selected, VS helps us generate the corresponding entity classes and database migrations, all we have to do is update the database to generate the corresponding table structure.

Open Tool-->nuget Package Manager--Package Manager console

Enter Update-database and run, after success, we look back at the remote Mywebsite database, help us to automatically generate all the table structure

Next, we run the CTRL+F5, the website starts normally as follows:

Back to top publishing site to server

Website local Operation No problem, we continue to follow the release of the operation, the project right click, select "Publish ...", temporarily we select the Local folder (after the project management, we then configure the remote publishing), the post-release generated files copied to the cloud server, here in the C:\MyWebSite directory.

In IIS management, check the Web site and deactivate the default Web site, because it takes up 80 ports and conflicts with what we want to build;

Right-click Add Web Site

As configured, use 80 port, HTTP default access port.

Click OK, so our site so far, the successful construction!

Use the browser, enter the extranet IP address to access our cloud server (if not, please check if the firewall is open 80 port, as set before the line):

OK, perfect ~

ASP. Build a personal website (1) _ Environment

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.