ASP.NET nothing changes when I edit the code - c#

I have this ASP.NET application, and suddenly it doesn't show the changes, if I edit a css file for example, even if I rebuild it and run it like that. I tried with an older version of the app too but it does the same. Is it from some Visual Studio setting?

If you are working with VS2015/2017, consider deleting the ".vs" folder that could be found at the root of your application i.e. the same folder where your solution file is present. If the folder isn't there you may have to unhide it through folder options.
The folder will get created again next time you build/run your application.

Try to clear the browser's cache.

Make sure you have tried "ctrl + f5" which will hard refresh (Cache will restore) your crome and make sure everything has been saved inside vs, Also make sure you are passing through the .css file properly.

Related

Updating resource strings for ASP.Net MVC does not change the output

I am trying to modify the string values for a resx file of an existing application. I have done nothing else apart from just changing the string value to replace a word (from "technician" to "agent"). File name and permissions are same, even the structure and naming convention is same.
Now, these changes do not reflect in IIS. I have restarted app pool, refreshed the application, double checked the permissions. Nothing seems wrong anywhere. I even tried the suggestions in older similar questions, but no luck.
I am not sure, if I need to recompile the whole solution, although, I believe that should not be the case. Do I need to do that? Also, will I have to republish the website from scratch, or can I just replace recompiled files in the IIS folder?
Or is there some other step I am missing?
You need to do a clean build and then just replace the main dll for your site in the bin folder. Sometimes Visual Studio doesn't see the change in resources and, in turn, it doesn't trigger a rebuild on your DLL. Clean build ensures the changes are built.
As per /u/Markus suggestion, I tried to build the code again. After changing the main dll file, and copying the resources folder again, it works.

HTTP error 500.19 - Cannot read configuration file

In one of my ASP.NET apps, all of a sudden I am unable to run it in Visual Studio 2013 due to the error displayed below. It appears that it is trying to open the web.config from a path that doesn't even exist. All of my project code, including web.config, are located under C:\Projects\SourceCode\AFEManager\Trunk\AFEManager.Web. I've found a number of posts here from users experiencing a similar error, but the solutions seem to vary and none I've found so far seem applicable to my situation. I looked in that TraceLogFiles directory and the most recent log file there is five days old so it obviously hasn't been logging anything since I've been having this issue. Any suggestions are appreciated.
In my case I deleted all folders in D:\My Documents\My Web Sites\ before
Then I caught the error
There is a file .vs\config\applicationhost.config in my solution folder
It contains reference to the deleted folder. So, I deleted applicationhost.config and then pressed 'Create Virtual Directory' button in my project property Web page. It was recreated the file and the folder
I've been able to resolve this issue even though I can't say I fully understand all of the details. I'll attempt to describe the situation the best I understand it and hopefully others with greater insight can add further clarification.
After having been doing all of my development on my workstation, it was suggested that I begin doing this work in a new VM environment that had been set up for me. So I installed VS 2013 there and copied my source code from various projects over there. However, rather than follow my previous local path convention of C:\Projects\SourceCode[ProjectName]... this time I decided to use the directories that are set up during the VS install, c:\users[MyUser]\My Documents\Visual Studio 2013\Projects[ProjectName]. Sometime shortly thereafter, our infrastructure team made a change so that my home directory, c:\users\rmayer, was now being pointed to a common network drive, \totalsafety\TSUsers\rmayer. Everything continued to work without any issues.
However, due to various difficulties I had working in this VM environment, I decided to return to doing my development work on my workstation using the original local paths for my source code. This is when I began encountering the errors described above whenever I would try to run my code through VS. What I've begun to learn is that there is an applicationhost.config file that IIS Express uses located here: \totalsafety\TSUsers\rmayer\My Documents\IISExpress\config. It contains entries for each of my web projects; the one relevant to this issue had a section which looked like this:
<site name="AFEManager.Web-Site" id="8">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\Users\rmayer\Documents\My Web Sites\AFEManager.Web-Site" />
</application>
<application path="/AFEManager" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\Projects\SourceCode\AFEManager\Trunk\AFEManager.Web" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:19257:localhost" />
</bindings>
</site>
The physical path attribute listed under applicationPool="Clr4IntegratedAppPool" at that time was set based on the local path I had been using at the time I was working in the VM environment. Now that this one file is being shared regardless of whether I'm working locally or within the VM due to the move of the users' home directories, this path is invalid when I'm working from my workstation. By updating this path to C:\Projects\SourceCode\AFEManager\Trunk\AFEManager.Web, it now works correctly from my workstation.
Again, I have a limited understanding of how this is supposed to work, but what it's telling me is that I will be unable to do development work from multiple environments (not that I want to any longer) unless the local paths are consistent between all of them. If I'm correct about this, this seems like a less than ideal design.
I had this issue when I moved the project folder to the new machine. The problem is that the VS has the site registered in its config file (applicationhost.config) inside .vs/ folder but did not create folder inside %USERPROFILE%\My Documents\My Web Sites\. If you just click Create Virtual Directory inside the project properties (Web tab) it will not be enough.
First close your VS and remove .vs/ folder inside your solution directory
Reopen VS and click Create Virtual Directory inside the project properties (Web tab) - VS will register the site again and create corresponding folder inside %USERPROFILE%\My Documents\My Web Sites\
I changed the virtual directory path in vs\config\applicationhost.config inside the solution folder.
In my case, the project was located on network not my local disk. After copying the project to local, the issue was resolved. Hope it can save someones time who has the same issue.
You can change the path for the web.config to its real path in applicationhost.config file. This file is located in /.vs/config folder.
After changing the path in this file, save it and restart the project, it solved my issue.
This is happening because I have different work stations, but the project is saving in different folders.
Delete .VS folders that Visual studio created.
It might be hidden in your project structure.
Unhide the folders and look for .vs folder and delete that folder and rebuild the application.
Most simplest way to solve this issue.
Approximate reason to arise this error is copy project from another pc.
Solution:
Step 01: From Visual Studio Solution Explorer, Right click on your project and choose Open Folder in File Explorer.
Step 02: Open .vs folder (Hidden Folder) and
you will get 2 folder named config and another one is named as
your_project_name/config.
Step 03: Both config folder will contain a
file named applicationhost.
Step 04: Open both applicationhost file using notepad and find the directory showing in error screen (Config
File \?\C:\User\hp\Documents\My Web
Sites\YourProjectName\web.config)
Step 05: Just replace this
directory according to your pc directory. Example, in my pc I have
changed as below:
C:\Users\Sydur Rahman\Documents\My Web Sites\MyProjectName-Site
to
C:\Users\hp\Documents\My Web Sites\MyProjectName-Site
Note: Please make sure you have changed in both applicationhost file.
That's all. Now your project will run as expected!
Thank you PongGod!! I am not able to comment on your answer but I wanted to post anyway since I had the exact same issue while running an instance of Orchard. In my case, everything had been running great until I found a bunch of old project files located in:
%USERPROFILE%\My Documents\My Web Sites\
And started deleting them for no apparent reason. I then tried to start up Orchard from Visual Studio in debug mode and received the error message above. After applying the same fix to my applicationhost.config file, everything is working fine now.
In my case, I am assuming that the directories got mixed up because I had initially ran the default Orchard files from Visual Studio and from Web Matrix. Then later on, I downloaded the full source files and began running the files from a completely different directory. Thanks again.
Here is a solution i have found.
https://gyorgybalassy.wordpress.com/2015/03/06/i-asked-for-a-vs-folder-and-the-vs-team-gave-it-to-me/
(1)Find the applicationhost.config file in |YourSolution|\.vs\config
(2)Modify the VirtualDirectory PhysicalPath To your project.
(3)Restart solution. Start project.
(4)If it's still not working, try to check setting in your IISExpress config. If there is not site setting, copy And paste the setting to |UserOnYourComputer|\Documents\IISExpress\config\applicationhost.config
(5)Change the id to other id which not be used in IISExpress applicationhost.config.
(6)Start your project.
I experienced the same issue and I resolve it quite simply. My issue was arose after when I perform a merge operation in git repository, after merge operation Visual Studio some how changed my default project URL to the default URL of my partner's computer from where he pushed the last time in to my repository.
So here is how I resolved this error:
Simply go to the properties of the project.
From the left vertically aligned menu, select Web.
After you will Project url and a text box containing the default port number, now just aside that textbox there is a button "Create Virtual Directory".
Press that button and there you go.
It will again point the default url the current working folder of your project.
Hope it works for you all :)
After all this answers I find my solution. Delete te WebSite in the IIS and recriate. Why? Because I had create de website before installed the framework 4.5 and URL Rewrite.
Go to the project dir:
..\\{ProjectDir}\\.vs\\{ProjectName}\\config
Then delete the applicationhost.config file and recompile your solution.
That's all.
This steps helped me to get over this error
1.In Windows Explorer, locate the web.config file that is associated with the Web site.
2.Right-click the web.config file
3.Click Properties.
4.Click the Security tab, and then click Edit.
5.Click Add.
6.In the Enter the object names to select box, type computername\IIS_IUSRS, click Check Names, and then click OK.
Note* Computername is a placeholder for the computer name.
7.Click to select the Read check box, and then click OK.
8.In the Web.config Properties dialog box, click OK.

Images don't show up after VS 2012 Publish

I have created asp.net web project. I have included some files in this project. Following all CSS standards required.
background-image: url('~/Images/sideheader.png')
I can see all pictures when I debug my site. But when I publish my site, I don't see any picture in my site.
Please help me resolve this problem.
When you manually add files (i.e. images/js/css) to a directory and use them directly in your html/css (as per your question) Visual Studio does not know they exist. You need to 'show all files' and then 'include in project' the images/files you want to publish.
Only the files which are visible (=included) in the Solution Explorer in Visual Studio will be published to your server.
You should use it like this :
background-image: url('/Images/sideheader.png')
in this way the relative paths resolves to the correct place .
Your URL isn't pointing to the file. It works fine on the debug server, because when you run it in debug, it starts up a testing server for your project that has a different configuration than the server you published to. Because you have it in a different directory, or have a different home directory configured, it can't find the image.
For anyone coming to this question, this was determined from testing if replacing the relative URL with an absolute one would solve the problem, which took place in the comment section of the OP.
You just need to add your folder images to your project and republish your project. To add the folder, go to solution explorer, click on show all files, right click on your images folder and select include in project. You don't need to change any urls of the images you have used in your css or any where else.
I ran into the same issue, in my case since the Images folder is not recognized by Visual Studio, I had to set read permissions to everyone. Once I set the Image folder permissions, my images showed up just fine.

asp.net file upload blank image files

I have written some code for saving an image to a folder in asp.net. My problem is that the image in the folder is white and is not the same as images added manually to the folder.
I used a simple asp.net fileupload control to save the file to the correct path. But the images dont display on the page and this is how the file icons look in visual studio.
Anybody know why this is?
Try Right-clicking the images and select "include in project"
edit
If you want to do that programmatically you need to modify the project file programmatically; that's all there is to it. It's an XML file with nothing special about it. Note, however, that you have this under source control and you'll probably need to do more than just modifying the project file (ie adding the file to source control too)
Yes, it is. Because it is not included as part of the project files.
Try this:
There isn't anything else that is wrong. Only the files are not tracked by VS, so they won't be published. Your files are still completely accessible from your code.
In my opinion, files like say images added to your web app shouldn't be part of the project.
You need to include them in the project by right clicking them and click Include In Project.
Furthermore, if you want these files to included in the build you need to go to Properties of each file and set Build Action as Content.

Could not find file 'obj\Debug\OldProjectName.csproj.FileListAbsolute.txt

I'm trying to publish project (tools vs2010), but cannot all the time getting the error below.
I paste to my projects files from another project and then I changed namespace (OldProjectName) to the parent project (NewProjectName). But it still getting information from somewhere about old project.
I cleaned solution, builded, rebuilded. Closed and reopened again and all the time the same error.
I'm able to build project but publish it.
Any ideas what can cause the problem?
Error 1 Copying file
obj\Debug\OldProjectName.csproj.FileListAbsolute.txt to
obj\Debug\Package\PackageTmp\obj\Debug\OldProjectName.csproj.FileListAbsolute.txt
failed. Could not find file
'obj\Debug\OldProjectName.csproj.FileListAbsolute.txt'. 0 0 NewProjectName
Open your .csproj file in notepad
Find "obj\Debug\OldProjectName.csproj.FileListAbsolute.txt"
Remove that line and save it
Open your project and try to publish it and this time you will be succeeded.
Note: if you are getting any more file like .pdb remove that as well.
Hope it will help you
Make sure the obj folder is not read only, if so change read only property of this folder to false. this worked for me.
Check the permissions to the folder obj\Debug\ if you give it write permissions, the error would go away.
Check if the folders "bin" and "obj" are checked-in to source control, if so delete those two folders in source control. There is no need to check-in these two folders to source folders. Also make sure that these folders "obj" and "bin" are deleted from your hard disk, they will be created again after a build.
Hope this will fix your issue.
It is your responsibility to make copies so you can go back to one.
Open your project file (vb/cs)proj with a notepad, and search for the missing files.
In my case I got this error when I tried to publish the project and certain files were not found.
Each publish attempt I got another file name, after checking that the file actually didn't exist in the project, I removed it from the project file, manually.
Then publish succeeded.
Delete the obj folder and build again.
Ref: http://forums.asp.net/t/1402005.aspx
Like many others these files were read only and needed to be deleted or actually able to be overwritten by VS. However, as may be the case for many others, the problem was because these files were checked in to source control. Your bin and obj folders should not be in source control. Mark them for delete and submit the changelist.
One exception to the rule is for the bin folder could be dll files that are not .Net compatible. Such as a C/C++ dll that you are using through a .Net wrapper dll. I mark them as content so that they get published and check them into source control.
I too had this problem. I resolved this by deleting files inside project bin folder (.dll and .pdb) and closed and re-opened VS .
The file named FileListAbsolute.txt was deleted from the folder obj/debug. Visual Studio can automatically recreate the file and others in the obj/debug for you.
For VS to recreate it, set the configuration of the solution and the project to debug mode. Then rebuild your solution.
To change the configuration mode to debug, from the solution explorer, right-click on the solution name and select Properties.
Select Configuration under Configuration Properties. Then select Debug from the dropdown list.
Click Apply and OK. Ensure that in Configuration Manager, the configuration mode is also a debug mode.
Then rebuild your solution.
For me using solution here: Certain Razor views not publishing
Excluding the views folder and re-including fixed it for me. So it's possible for anyone else experiencing this it may be as simple as excluding and then including the file/folder in question of your project.
I encountered this bug using VS2017 with a solution stored in OneDrive.I suspected OneDrive's sync mechanism to be the root cause of this.
When I tried to reproduce using VS2019 however it did not reappear. Looks solved in between these versions.

Categories