Build/Publish Single Page of Visual Studio 2013 ASP.NET Web Site - c#

I'm working on a ASP.net web project that was migrated from Visual Studio 2010 to Visual Studio 2013.
In VS 2010 when working on a page and it's respective code-behind you could right click the page in the solution explorer and click "Build/Publish" page and it would compile the aspx and cs into their respective aspx and dll files.
In VS 2013 things moved around a bit. You must now Build/Publish the entire web site. There is however an option if you right click the page you want to publish. However, all it does is stick the aspx and the code-behind in your "web_deploy" folder and that doesn't exactly work when you go to push it to your production environment...so my question is:
How can I publish a single page from my web project using visual studio 2013 without having to publish the entire site?

Publishing a single page is not recommended. As far as I remember ... VS never supported this ...
The risk of incompatible assemblies is very high. Updating the HTML only portion of a single page could work ... but again ... not recommended ... and is bad practice
The reason why publishing a single page is not recommended (nor supported) is because the code in each page is compiled into a separate page assembly. References to objects outside of that page are updated during the build process. Taking the built assembly for that page and inserting it into a web application does not guarantee that the linkages are consistent. At best it is considered "undefined behavior". It may work, but doing such in a production environment is poor practice.

Related

Migrating ASP.NET Web Application to Mac Rider

I have a project on VS 2019 Windows machine that is fairly small but containing Web Forms. I have taken the whole project folder zipped it and loaded it in directly to JetBrains rider on the Mac. Here is what it looks like currently.
1 Errors on solution
2 What the error says on every web form page
It appears that the System.Web.UI is not accepted on the Mac.
I have looked all over and the forums are telling me to download a package that proceeds it. This does not exist either. How do you replace the System.Web.UI?
WebForms are out of date and cross-platform of the web form is not impossible, but you will need to take into consideration everything that is used on the master page. It is not only a problem with MAC but any other IDE other than Visual Studio. You are better off migrating to the MVC style, it may take time but it appears to be the industry standard. WebForms are supported in Rider, however, you must manually create all the pages that belong with it like the master, and ensuring the routing is the same. Also, it seems to be severely difficult to connect an MVC application with WebForms. You would have to create the same exact style with _layout.cshtml and Site.master page. Seems like an outdated process that works if you want to just make forms.

Why automatic recompile doesn't work for C# classes in Visual Studio asp.net core mvc project?

I have an ASP.Net Core MVC simple project. When I start it without debugging (Ctrl + F5) and change any .cs File (Controller, for example), save it, and update the page in browser nothing happens. But it should automatically recompile and show changes, that was said in the book that I read.
Why can this happen?
I use Visual Studio 2019, .Net core 2.1.
If I manually close the page, and press start without debugging again it recompile and show changes in browser.
If I change .cshtml files (View) it takes effect as soon as I update the browser Page. So it is problem only with C# classes.
UPD dotnet watch works just fine for that purpose, but author of the book (A.Freeman, Pro ASP.Net core MVC 2 7th edition, chapter 6) did not use it:
Visual Studio supports detecting changes as soon as an HTTP request is received from the browser and recompiling classes automatically. To
see how this works, select Start Without Debugging. Once the browser
displays the application data, make the changes to the Home
controller. Save the changes to the controller class file and reload
the browser window without stopping or restarting the application in
Visual Studio. The HTTP request from the browser will trigger the
compilation process, and the application will be restarted using the
modified controller class
Why does this not work for me?
The book was written for Visual Studio 2017. It works as the book describes in VS 2017.
However, according to this, the auto-rebuild feature has not yet been added to Visual Studio 2019.
Original answer: (which applies when that feature is not available):
The difference is that .cs files are compiled into your project's DLL at compile time. For any new code to take effect, the DLL needs to be updated, which will only happen if you specifically tell it to recompile. This is why, when you deploy your project, you copy over the .dll file and not the .cs files.
However, views (.cshtml files) stay as plain text files and are compiled when you use them. If you edit a .cshtml, it's recompiled the next time the view is used. This is why, when you deploy your project, you do need to copy the .cshtml files.
Visual Studio does have a feature to let you modify .cs files while debugging and have it take effect immediately, but it doesn't support ASP.NET projects. It's called Edit and Continue.
However, you can setup dotnet watch to detect file changes and restart your application. There are instructions on how to do that here: Develop ASP.NET Core apps using a file watcher

ASP.NET MVC launching time

I have a big application which I develop (ASP.NET MVC), it wasn't initially mine and I received it from my client. When I run it via Visual Studio, it takes about 2-3 minutes to launch.
I'm wondering what is going on after pressing F5 button in VS (except copiling and copying dll's, views, content to output folder).
If I had to guess I'd say that you're compiling the cshtml code and that can be very slow in older versions of visual studio.
Check to see if you have
<MvcBuildViews>true</MvcBuildViews>
in your .csproj file.
see this answer
MVC Application is extremely slow to build
I believe every time you launch it from Visual Studio it creates new dll files, hence the waiting. But I could be wrong.

How to have Visual Studio 2012 returned compile errors on razor syntax error in "asp.net web page 2"? (Website package, not project or web app)

I'm using Visual Studio 2012 and I wrote some Razor scripts in *.cshtml. I'm not using MVC but "asp.net web page 2" (the term which is what Microsoft called it). It is created as website package (not project package or web-application).
When I compile it and run the website, I ran into a razor syntax error on the website. Upon closer inspection I noticed Visual Studio see the syntax error w/ red underline but it is allowed to compile anyway.
So, is there a flag or something I need to turn on in Visual Studio to enforce the razor errors. Yes, I know it takes longer to compile but we do need it cuz we can't see everything at runtime and we missed some of the errors when it was deployed to production site.
Thanks.
Web Site projects are compiled on the first request. There is no Build as such. If you want that level of protection, you need to ditch Web Pages and use either Web Forms or MVC - both of which allow you to create Web Applications.

Changes in Visual Studio 2008 not 'taking'

I've been consistently having a problem where changes I make to my web form or code-behind doesn't get recognized by the debugger until I quit visual studio and delete the "root" folder located in C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files.
It's very cumbersome and greatly decreases my productivity. Any help would be greatly appreciated. I've tried reinstalling visual studio, using visual studio 2010 and a variety of other proposed solutions.
Thanks very much
Update: On a hunch, I moved the project to the C: drive. (It was residing on a network drive)
No difference.
I added a control as a test and ran the program. Label shows up. Deleted the label. Ran the program. Label still there. Rebuilt the program; re-ran. Label still there.
This sounds like your are working on a compiled website project but have IIS running off the folder which contains the project you are working on in Visual Studio
When running like this there are strange issues that can occur where the site both has built classes in the Bin folder, as well as having dynamically compiled dll's in the ASP.Net temp folder and it really depends on the first line of your ASPX pages.
make sure the header of your aspx pages have CodeFile='pagename.aspx.cs if they are meant to be dynamically compiled and CodeBehind='pagename.aspx.cs is they are meant to be compiled by Visual Studio. You can't mix and match these two

Categories

Resources