Microsoft Visual Studio 2013: Cannot Create a new Asp.Net project - c#

File -> New -> Website -> ASP.NET Web Forms Site -> OK
Configuring IIS Express failed with the following error:
Filename: redirection.config
Error: Cannot read configuration file
So I've tried several solutions. I checked and already have IIS Express installed. I also am running as admin. I don't know what else to do and googling just tells me to turn it on (it's checked in my tools options)
File -> New -> Project -> ASP.NET WebApplication -> Web Forms Template -> Ok
Unspecified error(Exception from HRESULT: 0x80004005 (E_FAIL))
Are these related? Why can't I do anything related to ASP? My Documents folder is not encrypted.
Result:
I eventually got a new computer where this problem did not occur, so I did not personally solve this problem. Sorry.

I was having the same issue. Here's what worked for me.
Close Visual Studio.
Navigate to your Documents folder, and then the IISExpress subfolder.
Rename the "config" folder to something else. "configBACKUP" will do.
Open Visual Studio and try to create a new ASP.NET project.
IISExpress will create the necessary .configs in a brand new "config" folder.

Same issue due to having IIS Express 10.
Resolved by clicking Repair on it in Programs & Features.
Took 5 seconds and it was fixed.

User\Documents\IISExpress\config files try to uncheck Read Only property

In my case it worked fine after I went to IISExpress folder Documents\IISExpress\config and unchecked the "encrypt content to segure data" cause by default win 8.1 will encrypt it.

Related

Visual studio 2019 “Unable to connect to web server 'IIS Express'”

I attempt to lunch my ASP.NET Core project in Microsoft Visual Studio 2019 and got this error: "Unable to connect to web server 'IIS Express'"
Visual Studio 2019 Version 16.9.5
.Net 5.0
I tried this one and it worked for me:
Go to 'Debug Properties'
Find 'Web Server Settings'
Change the port in 'App URL' section and save the changes
Run the application and the same error will appear again
Switch the port back to the original port and save the changes
Run the application and enjoy it!
I hope this trick work for you.
If rebooting fixes this for you, then do this instead:
net stop winnat
net start winnat
The problem is that something reserved your desired port and made it unavailable.
See https://superuser.com/a/1610009/239292
1- Go to 'Debug Properties', Find 'Web Server Settings', Change the port in 'App URL' section and save the changes
In your project folder, delete .vs file, also remove the launch settings file in properties (make sure you copy to a different folder before removing it).
Restart visual studio and your machine if possible. Go to launch setting, check if they are properly configured similar to your prev launch settings. Run the application in IIS.
Should start working.
The following fixed the problem for me.
Delete the "properties\launchsettings.json" file.
The above solution has worked for other users too as per https://developercommunity.visualstudio.com/t/unable-to-connect-to-web-server-iis-express-in-vs/1027196
I encountered the same issue , but after few seconds i find out that there is a duplicated sslport , the same sslport being registered for another running app , so when i run another app with the same setting i see this error , you have to change the sslport in the launchsetting.json
From my experience this issue appears when the port used is already in use by other process. You will see the following:
Error description: The process cannot access the file because it is being used by another process. (0x80070020)
Just choose a port number which is free to use and the problem will disappear!
To me it has worked by switching the project from Debug to Release and Starting it.
When I switch back to Debug it starts correctly.
It appears to me that For some reason i had the Release project running so the Debug couldn't start.
I have just an API project.
Going to project's Properties\Debug and unchecking the 'Launch browser' helped.
In my case... (Visual Studio 2019, .net 5, blazor wasm project):
I did bkp copy of "Properties\launchSettings.json" file and ".vs" folder (just in case)
I deleted the "Properties\launchSettings.json" file and open the solution.. This file is recreated with default values...
After that, the error is gone and I was able to run and debug the application normally.
Now you can redo your updates on the "Properties\launchSettings.json" (i.e. change port).
In my case it was the wrong .net6 version. I work in a project with other developers. The main developer switched the project from .net5 to .net6. He has 6.0.3 installed, I have 6.0.2. Visual Studio did not show this. On the console with dotnet run, I get this error message.
My error message was regarding Kestrel web server: Visual Studio is unable to connect to web server... the web server is no longer running. I had to replace applicationUrl values from https://0.0.0.0:5001 to https://localhost:5001 . I got this error when I updated Visual Studio 2022 to 17.3.0
If you are like me and have probably tried all the above answers to no avail, here is a final solution that has helped me many times.
Answer: Do not restart your system (did this and it failed to work for me most times), rather, save all your work items, then shut down your system to allow all running process to shut down, then power on again.
If you do a restart, IIS Express may not get shut down completely, therefore, your port will still be used by the process holding on to it.
This works for me always
not sure if this answer will help anybody but I had made changes in appsettings.json file in Asp.net Core (net 6) and forgot to add coma after curly brackets
{
"AppSetting": {
"Token": "MY TOKEN"
}, ----------------------->here
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
Hence: you might find your errors in your warnings

The Operation could not be completed. The system cannot find the path specified

I created a C# Website using Visual studio 2015 in my laptop, i copied the same folder to my desktop system and open in Visual studio 2015, when i try to run the application its suddenly gives following error.
The operation could not be completed. The system cannot find the path specified
Anybody feel same error in your latest Visual Studio 2015? I updated all the latest patches.
following trial are done
Re created the soluition file(.sln)
Deleted Web.config and added new one
Still the error exists, so i cant able to debug or run the application.
(1) Run VS as an admin (or elevated access) and open the solution.
(2) Set up a project as Start up Project (if you have multiple proj)
(3) Set up page as start up page.
this should help you run it
Create manually (Windows Explorer if necessary) a folder with name "Service References". Even if the folder does not appear in the Solution Explorer, is there.
Try adding the wsdl (xml) file again.
I had the same problem, resolved by creating a Connected Services folder in my project.
So juste create a Connected Services folder or a Service References folder in your project
I experienced this error. When I shorten the file path of the solution, the error disappear. I think you may put your solution to a folder with too long path name or your solution have some file with too long name.
I got a more specific project-load error message when I removed the project from the solution and tried to re-add it. In my case, it was because the URL/address of the application had changed in my local IIS. When I updated the tag in the .vbproj (or .csproj) file to the new value, then the project loaded successfully.

[DirectoryNotFoundException: Could not find a part of the path

Im new in ASP.NET MVC C#, And I am using ReportViewerForMVC on my project.
With this one https://reportviewerformvc.codeplex.com/wikipage?title=Getting%20Started
On my local development I am able to find my report file like on this one reportViewer.LocalReport.ReportPath = Request.MapPath(Request.ApplicationPath) + #"Reports\YourLocalReport.rdlc";
All working on development mode but when I deployed my project., got an error [DirectoryNotFoundException: Could not find a part of the path ] which the code couldnt find the specific file.
My deployment package has no Reports folder on it. Is it the reason?
If yes, then how to add my Reports folder in creating the Deployment Package..
Developing on Visual Studio 2013, Windows 8
Deployed Server: Windows Server 2008 R2
Thank You
Right click the reports in your folder and set the Build Action to Content. That will include them when you publish.
I just got tripped up by this tonight - make sure that there are no spaces in your directory path - I was publishing to C:\inetpub\Corporate Webiste\ and when I removed the space it worked.

Visual Studio 2012 Deploying WPF via ClickOnce missing Files

I have a WPF project that I am ready to deploy using Visual Studio 2012 but I'm running into missing file issues. I've searched for hours to find nothing but incorrect information about VS2k12 not even having ClickOnce support to it being a bug in VS that was claimed to be fixed in an update but people still complain the update didn't fix it.
If I Start the project in VS it runs fine and my test button works as expected.
When I Publish the project, the publish succeeds, running setup.exe installs successfully and program starts to main window fine.
Clicking test button crashes the application on a FileNotFoundException.
Line that causes crash:
streamReader = new StreamReader("ReceiptTemplates/templates.xml");
FileNotFoundException:
Could not find file
C:\Users\dirt\AppData\Local\Apps\2.0\GEDD6PQW.N72\8M9ONPGG.TVB\prof..tion_40c30d08e677b188_0001.0000_985901e6c8ad767f\ ReceiptTemplates\templates.xml'.
Exists:
C:\MyProject\bin\MyMode\ReceiptTemplates\templates.xml
Confirmed Does Not Exist: C:\Users\dirt\AppData\Local\Apps\2.0\GEDD6PQW.N72\8M9ONPGG.TVB\prof..tion_40c30d08e677b188_0001.0000_985901e6c8ad767f\ReceiptTemplates\ReceiptTemplates\templates.xml
The templates.xml file has a Build Action of Content.
Note: There are other folders/files in the ReceiptTemplates folder that are present such as folder/item.html and picture.bmp, just not the templates.xml file that I can tell...
What am I missing?
Thanks to #drch for this:
In my case the ReceiptTemplates/templates.xml file was set to be a "Data File" and not "Include".
Solution:
Right click Project -> Properties -> Publish -> Application Files
Find file causing issue and change it to Include
If it says 'Data File' its in the data folder
If it says 'Include' its in the bin folder
Check in C:\Users\dirt\AppData\Local\Apps\2.0\Data for it ;)

The Web Application Project [...] is configured to use IIS. The Web server [...] could not be found.

I have a web project in my solution file that is "unavailable" when I open the solution. When I right-click on the web project and reload the project, I get the following error:
The Web Application Project mycompany.myapp.mywebproject is configured to use IIS. The Web Server 'http://localhost/MyWebApp could not be found.
I have not manually set up virtual directories for this web application.
Per colleagues, Visual Studio should prompt me to create virtual directories but I am not getting prompted.
I installed VS2010 before installing IIS on my dev machine.
Here is my development machine setup:
Windows 7 Enterprise
Service Pack 1
64 bit OS
Visual Studio 2010 Enterprise Service pack 1
IIS version 7.5
Since the accepted answer requires IIS Manager, and IIS Express doesn't have IIS Manager or any UI, here's the solution for you IIS Express users (and should work for everyone else too):
When you open Visual Studio and get the error message, right-click the project Solution Explorer and choose "Edit {ProjectName}.csproj"
In the project file, change the following line:
<UseIIS>True</UseIIS>
to
<UseIIS>False</UseIIS>
Save the file.
Now reload your project.
Done.
You'll then be able to open your project. If at this point, you want to use IIS, simply go to your project properties, click the "Web" tab, and select the option to use IIS. There's the button there to "Create Virtual Directory". It may tell you that you need to run Visual Studio as an administrator to create that directory, so do that if needed.
Open the project folder and delete {Project}.csproj.user, then reload the project on Visual Studio.
When this happens the easiest solution is to make the virtual directory manually.
First of all, you need to make sure you have the right version of ASP.Net installed and that you have installed the IIS extensions.
To do this, go to the relevant .net version's folder in C:\(Windows)\Microsoft.NET\Framework\(dotnetver)\
(substituting the bracketed folders for the right folders on your PC) and run this command
aspnet_regiis.exe -i
Next once that's run and finished, sometimes running
iisreset
from the command line helps, sometimes you don't need to.
Next, go to your IIS Manager and find you localhost website and choose add a folder.
Browse to the folder in your project that contains the actual ASP.Net project and add that.
Finally, right click on the folder you added and you should have an option that says 'convert to application' or 'create virtual directory' or something similar.
!!Make sure the Virtual directory has the name 'MyWebApp'!!
Reload your solution and it should work.
Please be wary; this isn't a programming question (and shouldn't really be posted here) but I've posted this guidance as it's a common problem, but the advice I've posted is generic; the commands I've listed are correct but the steps you need to do in IIS may vary, it depends on your version and your account privileges.
Good luck!
This solution worked for me: Right click the Project and select edit and find the following code as shown below in the picture.
change the <UseIIS>True</UseIIS> to <UseIIS>False</UseIIS>
OR
change the <IISUrl>http://example.com/</IISUrl> to <IISUrl>http://localhost/</IISUrl>
For my project, I had to delete these two lines from .csproj file
<ProjectGuid>{3AA499DF-4A65-43B7-8965-D08A4C811834}</ProjectGuid>
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
I tried deleting only the first one, but it wasn't enough.
EDIT: As many users have pointed out, this can change your project type or mess with your source control program. I can't investigate these issues as it was a school project I do not have anymore.
Please be careful when trying this. At least make a copy of what you delete.
Edit the .csproj or vbproj file. Find and replace these entries
<UseIIS>true</UseIIS> by <UseIIS>false</UseIIS>
<UseIISExpress>true</UseIISExpress> by <UseIISExpress>false</UseIISExpress>
In my case, this problem was caused by broken IIS bindings. Specifically, my 'http' binding had been deleted. Recreating it fixed the problem.
Cause: The IISURL inside project.csproj is not correctly reflected in the project setting, and the virtual directory was not created.
Solution: Change the Project URL to correct PORT and create the Virtual Directory to make the missing PORT available.
Follow Below Steps:
Step 1: Right click on the project file to Edit the project.csproj file.
Step 2: Search IIS and modify from <UseIIS>True</UseIIS> to <UseIIS>False</UseIIS>
Step 3: Right Click Project to Reload the Project. After Reload successfully, right click Project and select Properties.
Step 4: Locate Project URL option under Properties => Web
Step 5: Change the Project URL to IIS URL indicated both on the Error Message and on the <IISURL>http://localhost:8086 </IISURL> from project.csproj file. Then Click Create Virtual Directory. Save All
Step 6: Redo Step 2 so it doesn't impact the remote codebase and the server deployment settings.
This worked for me:-
Make all your IIS websites point to localhost(All Unassigned) only
Try opening Visual Studio with Administrator privileges. In my case, it gave access to the IIS site and made this error go away. I was then able to switch the project to use IIS Express which doesn't seem to need administrator privileges.
If you are connected via TFS, open your project.csproj.user file and check for
<UseIISExpress>false</UseIISExpress>
and change it to true.
<UseIISExpress>true</UseIISExpress>
You will not believe that, start visual studio as Administrator
as obvious from the message
The Web Server 'http://localhost/MyWebApp' could not be found.
could not be found because may it has no privileges to see it
so Just restart visual studio as Administrator
You can load the project without setting the value of attribute UseIIS to true.
Simply follow the below steps:
In the mywebproject.csproj file--
Delete the tag < IISUrl>http://localhost/MyWebApp/< /IISUrl> and save the file.
The application will automatically assign the default port to it.
In my case I wanted to switch from http to https, so I had deleted http from IIS. In my .csproj.user file found that I still had:
<IISUrl>http://localhost/</IISUrl>
So I changed it to:
<IISUrl>https://localhost/</IISUrl>
In my case I was able to open the solution in offline mode just running the command:
iisreset
For you Win8 users out there, if you follow the steps in the accepted answer, console spits out a message at you saying "thou shalt not use the command-line to execute this command" (paraphrasing). Instead, access the Programs & Features via Control Panel (or Windows + R > appwiz.cpl), click 'Turn Windows features on or off', and make sure you have the following installed:
Internet Information Services
> World Wide Web Services
> Application Development Features
> ASP.NET 4.5
This will check a bunch of other options as well. As soon as I installed these features, and ran VS2012 with elevated permissions, I was able to launch my app successfully.
This happens with me when I tried to open a project from the .csproj file, but I get over it by opening the project from VS:
File> Open> Web Site
and select the directory which include my project.
I had this error, too. I thought everything was setup correctly, but I found out that one thing was missing: The host name I used for my project was not (yet) resolvable.
Since my app determines the current client's name from the host name I used a host name like clientname.mysuperapp.local for development. When I added the development host name to my hosts file, the project was loadable again. Obviously, I had to this anyway, but I haven't thought that VS checks the host name before loading the project.
Check if IIS Express is installed. If IIS Express is missing, Visual Studio might discard the setting <UseIISExpress>false</UseIISExpress> and still look for the express.
in my case, make sure you have a "Default" website
In my case, the "Default Web Site" in IIS didn't have a binding for localhost on port 80.
You should have a binding for whatever your value in the .csproj file is.
I fixed this simply by reinstalling IIS Express after downloading from below link:
https://www.microsoft.com/en-us/download/confirmation.aspx?id=48264
Turns out my IIS was working on localhost:8181.Had to configure the {Project}.csproj file.
<ProjectExtensions>
<VisualStudio>
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
<WebProjectProperties>
<UseIIS>True</UseIIS>
<AutoAssignPort>True</AutoAssignPort>
<DevelopmentServerPort>7386</DevelopmentServerPort>
<DevelopmentServerVPath>/</DevelopmentServerVPath>
<IISUrl>**http://localhost:8181/ProjectName**</IISUrl>
<NTLMAuthentication>False</NTLMAuthentication>
<UseCustomServer>False</UseCustomServer>
<CustomServerUrl>
</CustomServerUrl>
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile><EnableWcfTestClientForSVCDefaultValue>True</EnableWcfTestClientForSVCDefaultValue>
</WebProjectProperties>
</FlavorProperties>
</VisualStudio>
</ProjectExtensions>
In my case, the url referenced in the csproj file was incorrect.
It needed to be prefixed with www.
I made the changes, saved the file and the project loaded fine.
I ran into this issue when the <ProjectTypeGuids> element in the .csproj file contained the unit test project GUID: {3AC096D0-A1C2-E12C-1390-A8335801FDAB}.
Removing it made the project load without problems.
For DNN users my issue was I needed a binding for dnndev.me at port 80. I have multiple installs that run on different ports and VS requires that that particular Url to exist on port 80 (not 86 like mine was).
Follow this completed solution step by step. it's works for me in VS 2017.
Open Command prompt in administrator mode
Open File explorer and got to .NET Framework folder
Eg:C:\Windows\Microsoft.NET\Framework\v4.0.30319
v4.0.30319 this is my .NET folder. you want to select your relevant folder.
in CMD - Go to .NET folder path
cd C:\Windows\Microsoft.NET\Framework\v4.0.30319
Execute below command in CMD
aspnet_regiis.exe -i
You can see this message finally - Finished installing ASP.NET (4.0.30319.0)
iisreset
You can see this message finally - Internet services successfully restarted
Open IIS in your computer (if not config Follow this)
Go to Site and right click
Add WebSite
Fill - Site name and select physical path
Then type port number (you can find port number in .csproj file and port number must equal with (IISUrl)
EG : <IISUrl>http://localhost:15724/</IISUrl> my port is 15724
Note : you cannot create port 80 number. because it used default IIS page
Click Ok
Open visual studio with administrator permission
Then right click and reload your project
Your Problem may be solved.
This may help some people in 2020. The main issue is that the IIS settings in the CSPROJ file don't match with the configuration for the machine. For example, if you had the Web Application Project pointing to localhost:12345, and a virtual directory isn't set up on the machine on that port, you'll get this error.
Using VS2019, I had this same issue, and the IIS settings in the CSProj file were being ignored. The reason for this is a new property in the CSProj file called "SaveServerSettingsInUserFile":
<ProjectExtensions>
<VisualStudio>
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
<WebProjectProperties>
<SaveServerSettingsInUserFile>True</SaveServerSettingsInUserFile>
</WebProjectProperties>
</FlavorProperties>
<UserProperties UseAjaxifiedTemplates="True" UseJQuerySupport="True" />
</VisualStudio>
</ProjectExtensions>
When this is set to TRUE, the IIS/Web server properties are in the
.CSPROJ.User file of the same project name.
This allows individual users of a project to have their own IIS settings, provided this file is not checked into source control.
You can control where the settings are stored using Visual Studio GUI in the properties for the project under "Web", "Apply server settings to all users"
When this is on, the IIS settings are stored in CSPROJ, when off, they are stored in CSPROJ.User

Categories