Run Web Application in Virtual Directory - asp.net

I am trying to run my web application for test purposes in a virtual directory.
I have done this steps from this MS Site
In Visual Studio, open an existing Web application project, or create a new one.
In the Project menu, click Properties, and then click Web.
Click Use Local IIS Web server.
Enter a URL for the project, and then click Create Virtual Directory.
But after this configuration I get a HTTP-Error 500.19 - Internal Server Error
Details: There are duplicate entries in the web.config File
But the web.config file hasn't changed. Without the Virtual Directory the site is starting up as expected.
any ideas?

Related

How can I get Visual Studio to automatically attach debugger to web Site not Application?

I have a web application required to run as a Web Site (root application). This is due to it being a multi tenant application that uses the urls sub domain prefix to know which client is accessing it. I create the site in IIS 10 setting the physical path to my Visual Studio 2017 .NET 4.5 MVC application and the site works fine.
I open the web project properties and under Servers choose Local IIS setting and set Project Url to the site I just created in IIS. Visual Studio then forces me to create a Virtual Directory for the Project Url, to save it, which then creates a Web Application under the default web site. You can't set and save the Project Url without being forced to create the virtual directory.
Now when I start debugging Visual Studio attaches to the Web Application not my web site so my breakpoints never get hit. If I manually attach to the w3wp process where the web site is running I can debug. I had this all working fine prior to recently switching to Git causing me to reconfigure things and I can't recall what I did to make it work.
How can I set the Project Url on web properties page without being forced to create a virtual directory? Or how do I make VS automatically attach to the Web Site and not Web App I was forced to create?
This blog might help: How to Debug Your ASP.NET Projects Running Under IIS
If your project is a website and not a web app, then here are the steps to configure it to use IIS when debugging. This assumes you already have IIS set up and hosting your project.
In the solution explorer.
Right-click on your project node and navigate to "Property Pages".
Navigate to "Start Options" item in the left pane.
In the "Server" section make sure "Use custom server" is checked.
In the "Base URL:" field put in the address you have mapped to your project. (Usually the address you put in your hosts file)
I finally discovered that setting the Servers 'Project Url' in the web projects properties page to 'http://localhost/' does not force you to use the 'Create Virtual Directory' to save the changes. You can't even change the default port here without being forced to create a virtual directory.

Routing issues after publish asp.net mvc app

I recently developed an asp.net mvc application that want to publish online. I used the Publish option on Visual Studio to do that.
Apparently this is a common task and there are several tutorials about that. However my case has a different detail that I believe is not allowing me to run the app successfully.
So the thing is:
I have a Wordpress site successfully running at www.somedomain.com
I want my asp.net application to run at www.somedomain.com/myapp
This is what I have done so far:
Uploaded all my app files to httpdocs/myapp folder on the server;
Configured a virtual directory on httpdocs/myapp folder on the server;
Imported the database from my local computer to the remote server;
Changed the connection strings on web.config to point to the database on the remote server;
After this, when I try to access on the browser to www.somedomain.com/myapp I can see that it redirects me to www.somedomain.com/myapp/Account/Login?ReturnUrl=%2Fmyapp%2F but shows the 404 error (Page not found) with the layout of my Wordpress site. So it looks like it is running the Wordpress site, instead of the asp.net app on that folder.
are you using IIS?
you need to create an application instead of a virtual directory
otherwise it will not treat the sub folder as an application and will follow parent folder’s web.config and other settings

Deploying WCF webservice to IIS

I'm trying to deploy a wcf web service to IIS 7.5. Is there anything special I need to do in order to make this work. I keep getting 404 error when I try and run the web service. I can't seem to pull up the wsdl file either.
These are the steps I've taken
Right-clicked on web service project and published to local folder
Copied contents of publish to IIS server
Setup a new website that points to folder with webservice files
set binding to match web.config binding (port #)
Is there anything I missed or overlooked. Shouldn't I be able to run that web service from IIS and load up the wsdl file directly on the server. When I test in visual studio, it handles the loading of that host program.
Apparently you have to load the .svc file path which I was not doing.
Just to expand on this a little, since this question got me started but there were a couple of extra steps I had to take:
In VS2012 right click on the web service project and select Publish
Publish to file system by selecting a directory to publish to
Copy the folder contents into a folder on the server
In IIS create a new website, its physical path being where you just copied the published contents to.
Set its app pool appropriately (probably .NET 4.0)
The binding port should be the same as in the web.config as should the name. So if you've been working locally and your web.config reads "http://localhost:12345/MyService" then hostname is "localhost" and the port is 12345
You can then browse to the webservice by right clicking on the website in IIS -> Manage Website -> Browse. Click on your service name.

asp.net website deployment in IIS

I have a very simple website which displays Hello World. I tried to deploy this project on the server. These are the steps I followed:
Copy the folder of the project to inetpub/wwwroot folder.
In IIS management, created a website. Gave the path of the website from step 1.
Gave the application pool as .NET 3.5
After doing the above, while browsing the page, I received the error- Type not found in web.config.
Check to see if you can browse a simple image there. that is, copy a jpg to the root of your web site and try to open it.
paste your web.config, that would be a help.
(app pool is set from advanced options in inetmgr program)
Add all website(or application.exe) files to the IIS Virtual Directory instead of wwwrootfolder. (IIS virutal directory is created by you while configuring IIS server)
Or
New Website
Under Locations Click on "Browse"
Click on "Local IIS" and then select the "IIS Virtual Directory"(IIS vitual Directory which is directory created by the user while configuring IIS server)
Open manually using Explorer drag and
add all you files to the "solution explorer"
then "Yes to all"

How do I deploy a pre-compiled ASP.NET web application?

I have a web service implemented in ASP.NET 2.0 and have pre-compiled it using the aspnet_compiler.
I have no clue now how to deploy it to IIS, can someone point me in the right direction? I am using IIS 6.0 on a Windows Server 2003 machine.
I have placed the pre-compiled files into a virtual directory, when I access the service through the browser I get the following parser error message:
Parser Error Message: The page must have a
<%# webservice class="MyNamespace.MyClass" ... %> directive.
I then checked the .asmx file for said directive and the contents have been changed by the compiler to:
This is a marker file generated by the precompilation tool, and should not be deleted!
UPDATE: When I place the non-pre-compiled web app in the virtual directory it works fine, when I place the pre-compiled wen app in the virtual directory, I get the above errors.
Anyone have any ideas!?
You can either copy the contents of the output directory into the virtual directory on IIS and it should all just work. You will need to set up the App Pool and configure the virtual directory for ASP.NET just like a non-compiled website. Make sure you delete everything from the virtual directory (if there was a previous non-compiled site there).
Also you can use Web Deployment projects, which can serve as an input to an MSI installer.
The ASMX file contents are correct. Are you sure you have configured the Virtual Directory with an Application? Open the properties window by right clicking on the virtual directory and ensure the "Application Name" (on the "Virtual Directory" tab) is set and is editable.
Also have chosen the correct ASP.NET version on the tab? Check this on the "ASP.NET" tab of the properties window"
did you deploy the entire bin directory? You need to make sure the .COMPILED files created by aspnet_compiled are in your bin dir.

Resources