I have to fix a legacy web service project created in C# and asp.net. It is not possible to open the project in visual studio as source safe errors and other missing libraries cause too many compile errors. I am not that familiar with web applications in .NET.
Is it possible to update a single aspx.cs file in the website directory which has a connection string hard coded that needs to be updated. If so, how is this eventually compiled and updated in IIS?
After you've deployed to IIS, you cannot update the .cs file in ASP.net application as they are already compiled into .dll files in the bin folder. The files you can update are with extensions like .aspx .ascx and .config etc. You should modify the .cs file, compile and publish the dll into the bin folder.
Related
We've recently started using the Web Deployment method offered in Visual Studio. For projects that have a single project in each solution, the deployment works fine and all files are copied correctly to the IIS server.
However, we have some solutions that have multiple projects in them. (2 or 3 projects...never any more than that.) There is a main project and some additional sub-projects. When the deployment happens, all the source .aspx and .cs files from the main project are copied to the server as well as all the output files in the bin directory, however the .aspx and .cs files from the sub-projects are not being copied to the server.
How can I get the deployment process to include the other supporting files in the sub-projects?
My boss asked me to make changes to a web application which resides in svn. Not much is known about the development of this application as it was done years back.
I did check out the folder and noticed the is a bin folder as well as App_Code with all the associated .aspx and .aspx.cs files as well. What is missing though is the .csproj file.
How do I create one so that I may open it in visual studio and make changes and rebuild accordingly?
I was just handed a C# web service project and first time doing C# and ASP.NET. The web service and .cs, asmx, and asmx.cs files are located in wwwroot dir of the IIS server. I am writing a PHP SOAP client that calls those asmx files via SOAP. I would like to change some of the hard coded settings in those asmx.cs and .cs files. I have tried the aspnet_compiler and Visual Studio would not load the project. Is there any way to update the code/logic in those files without Visual Studio or recompiling. This project was compiled before. When using VS 2010 - it tries to open the project, converts it and nothing happens. If I have to us VS - any clues why it is not loading those files? It opens them if I open the .cs files individually but then I can't rebuild the project.
Any help/hints would be appreciated.
Thanks
It seems that your project file (.csproj) is interrupted. Refer to other correct project file and fix it manually.
ASP.NET website will auto compile cs and run when asmx first requested. Compiled code is put at bin folder, while cs code is put at app_code folder. Make sure asmx code behide puts to cs file in app_code.
Sorry but it turned out be a Windows profile issue. VS could not load those project files due to my profile being full. Hope it helps someone else in the future :)
Got a Visual studio 10 solution for ASP.NET web site, and VS seems to compile *.aspx.cs files that are in the web site folder, that used to be part of the solution but were excluded (I no longer see these files in the solution explorer). Is it expected? If not, how could I fix it? Rebuilding solution does not help.
Also, is it expected that I cannot find the binaries for *.aspx.cs files?
If your website is a Web site project as opposed to a Web application project (see Web Application Projects versus Web Site Projects in Visual Studio) then IIS will perform the compilation at runtime for you instead of Visual Studio - in this case the .csproj file is not used to determine what is and isn't compiled.
There is no project file (.csproj or .vbproj). All the files in a folder structure are automatically included in the site.
I'm not sure where the compiled binaries go, but I believe that it is a temporary folder somewhere, so you shouldn't necessarily expect to see those binaries in the web site folder structure.
If you want explicit control over what is compiled and when it is compiled then you may be better off converting your project to a web application project.
Short answer: No. It only compiles whatever is is included in the .csproj marked as 'compile' (in the file properties window).
Try to refresh the project, open the .csproj as a file text and check if those files are referenced there.
Lastly, it might be a dependent project that references those files.
If you can't find the solution, paste the exact error given by VS
For clarification, solutions files (.sln) contains project files (.csproj); .csproj files are the ones that contain references to the files to build.
When server knows when to compile project ? If I change aspx file it detects changes and compile it on request ? What about changes in cs file ? Thanks for any help
Basically, it depends on your project type.
Web Site projects are compiled on the fly and any code modification in the site folder will trigger recompilation on execution.
Web Application projects need to be manually compiled (you'll see a [your project assembly name].dll in the bin folder).
Also, check http://msdn.microsoft.com/en-us/library/dd547590.aspx for more information about the difference between the 2 project types (and how they are compiled).
Using VS 2010 you may create ASP.NET Web Application or ASP.NET MVC Application using .NET 2.0 - 4.0 of your choice.
The next details are applied for both ASP.NET Web Application and ASP.NET MVC Application:
aspx files most of the times contains only static HTML code and after you change it you don't need to recompile the whole project because server pickup your updated aspx file strait away. With cs files is different story, because in that case when you did any changes in cs file you need to compile it to produce new updated dll files which would contain your latest changes.
So if you did any changes in your cs files and did not recompile the project, your changes won't be available until you recompile the project.
Also using VS 2010 you may create ASP.NET Web Site application. In that case you don't need to recompile your project if you changing cs file. Your source code will compiled automatically by ASP.NET on the server after first request.
More about Summary of Differences between ASP.NET Web application projects and ASP.NET Web site projects you may find here: http://msdn.microsoft.com/en-us/library/dd547590.aspx
With all the project types that exist in Visual Studio 2010 you have to recompile your code every time you make any changes in your .cs files.
In VS 2005 and 2008 there was a project type named "Web site", with this project type you did not have to recompile if you made changes in a code behind file.
For more information check out the differences between CodeFile and CodeBehind.
/Viktor