how to host asp.net app locally - c#

I have a ASP.NET website, developed by a freelancer. After developing the website, he directly uploaded the website to my domain. Now, how can I host that website locally on my computer?
I dont have any experience in ASP.NET, however I do know HTML5 and CSS3. Looking at the files, I noticed they are all .cshtml files.
Any help would be great. I have the login credentials of Plesk.
Thanks in advance

You need to use IIS.
To do this, assuming you are on Windows, you need to enable it under the 'Windows Features' setting screen as below:
Check the 'World Wide Web Services' option, and also 'IIS Management Console' under the 'Web Management Tools' section.
After it installs, you will have a new program in your start menu, called 'Internet Information Services (IIS) Manager'.
This is where you setup and configure any local websites. There will already be a default website set up, which you can use, or you can create a new one by right clicking on 'Sites' in the tree on the left, and selecting 'Add Website':
Assuming you just use the default, you will need to copy your application to C:\inetpub\wwwroot\. You will then be able to access this by pointing your browser to http:\\localhost or http:\\127.0.0.1.

Assuming you are working with Windows, you will need to install an IIS on your machine. IIS is a part of Window's features, you can try installing it under:
Control Panel > Program and features > Turn windows features On / Off > Internet Information Services.
In some versions of windows, IIS is not available. In that case, you will need to download IISExpress.
After that - Configure a new website under your IIS, and point the website to the directory in your computer which has the project.
Read more here:
Installing IIS
Setting up a website

Related

How do I run an already existing asp.net mvc application om my local server

I am front-end developer trying to brush up the front-end of an existing asp.net mvc application. So I have never used asp before but I thought I would try running it locally on my machine then get to work on the css part of the web application.
Previously I have tried running IIS server locally but in vain, is there a better way to run this project? Sorry I am not allowed to share the repo from where I have cloned the project.
I am using Visual Studio code running on a Windows 10 machine.
I would suggest using Visual Studio. It has its own IIS Express so you can run app locally and open it in any browser and you can also edit all HTML and CSS files.
The Best way to use latest Visual Studio and import your project into it (File->Open-Project/Solution) and run the application in it in debug mode. You can put break point to go through the code and add new codes and even test your application. It is very easy indeed. It has all the utilities for a .NET MVC application.
Open IIS, go to Under Default Web site.
right click and add select Add Application
give alias name and select the physical path of your source code
click Ok
if you get database access Authorization failed.
Open SQL Express Management Studio as an “Administrator” and navigate to Security > Logins > NT AUTHORITY\SYSTEM
Right click on “NT AUTHORITY\SYSTEM” and select Properties. Select “Server Roles” from the left panel and make sure that “public” and “sysadmin” are checked.
Your application will be added under Default Web Site
from there you can browse.
You can have a look at very good article,
how to deploy ASP.NET MVC application on IIS

How to deploy an ASP.NET application to localhost using IIS?

I'm trying to deploy an ASP.NET application to localhost using IIS, I've been reading a LOT of tutorials and following them step by step but I just can't seem to make it work...
I created an Application Pool(TestPool) with .NET version 4.0 and gave it every permission to the folder where the application is at.
I then added an application to the Default Web Site and tried to run it at
http://localhost/TestApplication/
But I keep getting:
Any idea what is wrong and how can I solve this?
Versions:
IIS version: 6.2
OS: Windows 8.1
VS 2013 Ultimate: 12.0
VS .NET: 4.6
PS: It's my first attempt at deploying an ASP.NET application so if you need any further information just leave a comment.
EDIT:
It is now running at least thanks to Julian and Marge, but when I run it using VS it has the default view, why isn't it showing when I run it through IIS? When running through IIS it just lists the files:
This error is because your website, in the IIS Server, does not have the Directory Browsing enabled and the default document (default page of the site ex: Default.aspx) configured.
Go to IIS Server IIS > Default Documents and check if the default page of your site is listed, if no, add the page.
Check the related link:
https://support.microsoft.com/en-us/kb/942062
Generally speaking, you do not need to access IIS manager at all to run your webpage on localhost. All what you need to do is right click on the project and then choose properties. In the Web tab you will find Servers section. Make sure the Project Url is something like http://localhost/myproj or simply http://localhost/ then hit Create Virtual Directory. Your webpage should be up by then, and you can access it either in debug mode, or simply by navigating your browser to the Project Url you have chosen.
When you add web application in IIS ex.
That your hostname should be to add in host file which is C:\Windows\System32\drivers\etc"\hosts
ex.
127.0.0.1 test.pln

Run MVC4 webapplication on local IIS webserver

UPDATED - pointed to the wrong directory at first. Thanks for the tip Wiktor. Still not succeeded in running the MVC4 application via
I am trying (for a while now.. :)) to set up a simulated multi tenant webapp on my development PC. I learned that this is not possible with visual studio's internal webserver, so I am trying to set up IIS.
I added the fake tenants in my hosts.
127.0.0.1 localhost
127.0.0.1 tenant1.mydomain.com
127.0.0.1 tenant2.mydomain.com
In IIS I made a new website test(port 8081), and just pointed it to C:\Azure\Websites\. In that directory I added a Hello World html file to see if this bit works.
I navigated to localhost:8081 => Hello world
I navigated to tenant1.mydomain.com:8081 => Hello world.
Cool, first proof of life.
Next step: getting this working with a MVC4 webapp created in VS2012.
I started a new MVC4 webapp and stored it in:
C:\Azure\Websites\MvcApplication1
I just use the default generated website for the test, so I pressed F5 and verified the site is opened in firefox. So the goal is to get this working from IIS.
Created a new website test2 (port 8082)
Set test2 app pool to .net4.0
Point the physical directory to C:\Azure\Websites\MvcApplication1\MvcApplication1\
Navigate to localhost:8082
HTTP Error 500.21 - Internal Server Error
Handler "ExtensionlessUrlHandler-Integrated-4.0" has a bad module "ManagedPipelineHandler" in its module list
Uninstalled ASP.NET and reinstalled it again. Same results.
when I change web.config from
preCondition="classicMode,runtimeVersionv4.0,bitness32"
to
preCondition="integratedMode,runtimeVersionv4.0,bitness32"
Then I get this error:
HTTP Error 404.2 - Not Found
The page you are requesting cannot be served because of the ISAPI and CGI Restriction list settings on the Web server.
Can I stress the fact that I am a n00b regarding IIS configuration... :)
Any ideas?
ISAPI and CGI Restictions in IIS:
Add isapi dll for .net 4 32bit
Add isapi dll for .net 4 64bit
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll
C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll
And it works. Finally!
Thanks Wiktor
First configure IIS according this site:
IIS 7.5 handler "extensionlessurlhandler-integrated-4.0" has a bad module "managedpipelinehandler" in its module list
For the above issue, you must go to Control Panel >> Installed Programs and Features >> Repair your .NET Framework by double clicking on it.
first configure IIS as
Manual configuration
Open your Control Panel and click Programs and Features » Turn Windows features on or off.
Turn on Internet Information Services.
Under Internet Information Services, turn on the following features:
Web Management Tools » IIS 6 Management Compatibility » IIS Metabase and IIS 6 configuration compatibility.
Web Management Tools » IIS Management Console, IIS Management Scripts and Tools, and Management Service.
Under World Wide Web Services, turn on the following:
All features under Application Development features, except Server-Side Includes.
Common HTTP Features » Default Document, Directory Browsing, HTTP errors, Http Redirection, Static Content.
Security » Basic Authentication, Request Filtering, Windows Authentication.
Under Microsoft .NET Framework 3.5.1 » Windows Communication Foundation HTTP Activation.
After you have created your website, open the Internet Information Services (IIS) Manger.
Expand your server node.
Expand Sites node and click your website.
In section IIS on the right, double-click Authentication.
Perform one of the following:
If you are using Forms authentication, make sure Anonymous Authentication and Forms Authentication are enabled and all other authentications are disabled.
If you are using Claims-based authentication, make sure only Anonymous Authentication is enabled and all other authentications are disabled.
Click your website again and in IIS section, double-click Handler Mappings.
Make sure you have enabled handler mappings for *.svc and *.xamlx with executable path set to one of the following:
For 64-bit OS: %windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll
For 32-bit OS: %windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll
Close the Internet Information Services (IIS) Manger.

How to make Web Application project a standalone with IIS Express and SQL Server Express?

How can I make Web Application project a standalone desktop application with IIS Express and SQL Server Express?
With "standalone" I mean clicking on an exe-file start my application (e.g. start.aspx in my browser). The whole application consists of lots of aspx-files which run in a browser.
NOW: I have my Web Application project running fine when pressing F5 in Visual Studio 2010.
MY AIM: I want to start this project on a local machine just as easy as it is in Visual Studio, but how could I do so?
You're misunderstanding what happens when you press F5 in Visual Studio.
When you press F5, and if you're using the Visual Studio Development Server instead of IIS, that server is started up, and can serve requests for your application that come in on localhost. In any case, Visual Studio next starts your default browser and tells it to browse to your web application. The only application being launched on the desktop is your browser.
When your application is ready for other users to use, you will need to deploy it to a web server. Once it is deployed to the web server, users will be able to open their browser and browse to your application.
There is no simple way to package up a web server, database server, and your web application into a single .exe that a user can double-click.
i recommend you look into this product
http://ultidev.com/products/UWS-Cassini-Pro/Default.aspx
You'll need to use SQL CE, which has a number of limitations, such as the inability to auto-increment identity type columns.
Why would you use IIS for a stand-alone desktop application? A web application is for the web. If you want desktop that look into WinForms of WPF. I doubt you will find any tools to do the conversion for you so you will have to make it a manual process. Just hope you have a well structured web app.
Unless of course, you mean to just access a local web application from your local machine IIS installation? If so, then just set up IIS like you would do on a server, assign yourself a port to the localhost to access the web application and then create a nice desktop shortcut that links to the correct URL

How to enable Windows Authentication on ASP.NET Development Server?

We are trying to host a WCF service via the web. We set the web.config to have the service require windows authentication. The problem we are having is the following:
When we host our service in a regular IIS, the service runs fine and there is no issues with the "Windows Authentication" mode. However, when we try to run it from our developer boxes we get the following error: "Security settings for this service require Windows Authentication but it is not enabled for the IIS application that hosts this service."
Our developers boxes are not hosting the service through the regular IIS but rather through Visual Studio's ASP.NET Development Server. We tried going into the web project properties and said to enable NTLM authentication but that still did not fix it. Does anyone know how to fix it? Does VS ASP.NET Development Server even support Windows Authentication? Is the only option for hosting the service with Windows Authentication is to use IIS and forget about ASP.NET Development Server?
In order to configure IIS Express security settings:
look for the IIS express symbol in the taskbar (system tray).
Right click and select "All Applications".
Click on the name of the site you want to change (although I believe the change is site wide)
Click on the path in the config section below (it will open the applicationhost.config file)
Search for the authentication section and make your changes
Example changes can be found here:
http://toadcode.blogspot.ca/2011/08/security-config-in-iis-express.html
ASP.Net Development Server is very limited. It only serves requests originating from the same machine that it is running on, and it will not serve files that are outside of its application scope. It is based on the Cassini server. Cassini does not support WCF web services. Documentation for ASP.Net Development Server says that it does support NTLM. If you are just browsing to a page from the local machine it should work fine unless the page is referencing an unavailable resource.
check out http://msdn.microsoft.com/en-us/library/58wxa9w5.aspx for more info.
I would install and configure IIS on your local dev machine and use that in preference to using the inbuilt webserver. To use local IIS to debug select "User Local IIS web server" on the web tab of the project properties. Using IIS rather than the inbuilt webserver also means that you can configure your app in exactly the same way as it will be configured on the production server and this will reduce the no of potential surprises when you move to the production environment.
The solution to my authorization issue was to go into the F4 project properties and set the following:
Anonymous Authentication: Disabled
Windows Authentication: Enabled
Apparently these properties update the IIS applicationHost.config directly.
http://provenstyle.com/blog/2015/10/02/Visual-Studio-2015-Windows-Authentication-And-IIS-Express/

Categories

Resources