Unable to make changes to ASP.NET Code Behind while Debugging - asp.net

I've created a new ASP.NET Web Application for my project. While debugging, Visual Studio is not allowing me to make changes to my code behind (default.aspx.cs).
When I try, I get the "Edit and Continue" dialog letting me know that "Changes are not allowed while code is running or if the option 'Break all processes when one process breaks' is disabled.
but I'm able to edit my default.aspx
Am I missing an option somewhere?

I know exactly what you mean. Turn off "Enable Edit and Continue" setting (in tools->options->debugging->general). Now you can edit .aspx.cs Content while it's debugging on Local IIS.

You are allowed to changes ASPX page because this page is going to be rendered at client side and changes made in page will be directly affected to client browser.
But When you change in CodeBehind visual studio will not allow to change the code because your code needs to be compile again and dll generated to your application needs to be created again with the updated code. That is why it will not allow you to change it.
If you want to change code, you will have to stop the application, change code and run the application again.
If you want to change the value of defined variable at debug time then you can directly change it by moving cursor on it and reassigning value.
Another option to change the value of variable at debug time is from Immediate window.
If you still want to update the code then follow below steps :
Right Click on the Project
Select Properties
Select Web in Right Panel
Check 'Checkbox' at the bottom saying : 'Enable Edit and Continue'
Refer : http://blogs.msdn.com/b/visualstudioalm/archive/2013/06/26/debugging-support-for-64-bit-edit-and-continue-in-visual-studio-2013.aspx

Probably you need to change this when running and debugging multiple projects at the same time:
Break All Processes When One Process Breaks
http://blogs.msdn.com/b/zainnab/archive/2010/10/22/break-all-processes-when-one-process-breaks-vstipdebug0029.aspx
Perhaps yesterday, you was working only with one project and today you are debugging multiple projects. Thats the difference.
Anyway, first answer is good too.

Related

Can not save transformation changes in Kentico Portal engine - errors in the console

I have a running Kentico 11 portal engine site and need to update the transformations in my navigation menu control. Something I have done many times before.
Today I went through all of the steps and the save button does not update the code. It never displays the change were saved messaging.
When I open the browser dev tools I see several errors on the page:
errors
A couple of things to check.
Is this happening in different browsers, also?
Can you save other transformations?
On this particular web part, if you select a different transformation, will that save successfully?
And, is the event log registering any errors?
Sounds like it may be a caching issue. What I'd suggest is the following:
restarting IIS
Open a private browser window and log in
attempt to make an edit to the code in question
If this does not resolve the issue, have you made any changes recently to the web.config, in particular the CMSHashstringsalt value? If so, this will cause your macros to become invalidated. You'll need to go to System > Macros > Signatures and check both boxes and resign the macros. It may take some time depending on your site but this could also help resolve your issue.

How to open specific web page in ASP.net that I'm working on or find pages that referring it in Visual Studio 2017

I've edited an ascx.cs page which I thought was relevant. When I ran the service to debug that code it wasn't the right place - The breakpoint didn't stop the service.
I know how to find the right page to edit but now I want to see what did I edit.
How can I open the page or find which pages are referring to it so I could check it also?
Have you "set as startup" that project already ? then try setting that page aspx.cs as "startup page".
After setting above both , your project will start that same projects same page that you have set up as startup.
Alternatively you can type link to that manually in address bar to get there.
While trying to set it as startup page I've found out it ascx and not aspx file. So if You want I wanted to see the edits I would need to load that page as asp controller.

Give the project result to the client in asp

I have a basic question
I started to work with asp for a client, and I built some pages with buttons and grids and so on, and now I want to give him the result of the work.
How do I do it?
In a "normal" application - I give him the exe file and all the dlls, but in asp I didn't found any of this, so what I give to him?
thanks
Continue from comment ...
Right click on web project, and click on Publish...
Then create a new profile, and select File System at Publish method.

Visual Studio 2008/2010: How to get custom user controls to show in the markup's intellisense immediately?

What I do is 1) add new user control to project and 2) register it in the directive of the page I want to use it on. When I go to use it, it's not yet available in intellisense. It appears I have to close and reopen the project in order for it to be available to intellisense. This has been my experience for many years with different installs of VS 2008/2010 on various machines and I am finally getting around to question why this is the case.
It takes a minute to propagate to the editor, but you can still declare the control in markup without any errors. Chances are by the time you're done declaring it, intellisense will have caught up.
I don't know if it's any faster, but you could try registering the user control(s) in the web.config. If you plan to use the control(s) in more than one place, the web.config would be more appropriate anyway.
Normally, I add my controls to the web.config, then do a "Rebuild" of the solution / site. I've never had any trouble with intellisense / control access after doing that... though I could be lucky.

Debugging with Response.Write in classic ASP

I am trying to debug some code using Response.Write, but when I run the code it skips over that statement and errors out at some point further in the code.
How can I get my Response.Write statements to show without the other errors coming up?
I quite frequently use Response.End when I have to see a status in a certain place on a page.
We utilize Visual Studio 2008 to debug classic asp pages. You can attach to the IIS process and "step through" the page. Its very sweet. Here are the steps:
Get latest of the classic ASP from source control.
Install IIS (if not already). FYI... I am using IIS 5.1.
Create a virtual directory called "classicDebug" pointing to your local directory (C:\Websites\ClassicWebSite).
View the virtual directory properties, Virtual Directory tab.
Enable the "Script source access" checkbox.
Configuration button, Options tab - check everything.
Debugging tab - check everything.
7a. In the ASP.NET tab, select 2.x
Load up (not run or debug or F5) the website in VS.NET 2008.
Edit your global.asa accordingly (data sources, and paths).
Find the .asp page you want to "step through" and set a break point at the top (or somewhere).
Open IE, and navigate to your page.
Go back to VS.NET and select Debug -> Attach to Process
Check "show processes from all users" and select the process. For me (IIS 5.1), the process name is dllhost.exe running with the IWAM_COMPUTERNAME account w/type "Script, T-SQL, Managed, x86".
Visit your page using IE... VS.NET should break.
Comment out the line which gives the error and see what the respnse.write is displaying is the only thing reasonable.
Don't use the on error resume next while you are developing your pages. You have to make sure that you building your pages correctly and that your are producing correct code. You wont see any errors if you use on error resume next.
on error resume next should only be used, in my opinion, in database actions and in delivered (non-developning) code. In that case you should use the
if Err.Number <> 0 then
construct to test any errors. You simply cannot do that after every line in asp if you have put the on error resume next statement at the top of your code, but it certainly makes sence in database handling code.
You will have to use "on error resume next" statement on top of your ASP page. This will solve your problem when an error occurs it will move to next line rather than throwing an error.
You can check this link http://www.powerasp.com/content/new/on-error-resume-next.asp for reference.
Happy Coding
Try a Response.Flush after your debugging statments, or setting Response.Buffer to false.
This might help as an alternative to response.write.
I put together this ASP include class which works with Firebug+FirePHP. It allows you to log values (including strings, multi-dimensional arrays and even objects created with json.asp) to the firebug console and view ASP's built in collection objects which can help (particularly with Ajax where you can't output debug data without breaking the json response.) Ajax script load times and errors are automatically logged for quick viewing.
https://github.com/dmeagor/ClassicASP-FirePHP
Just include the file and use log(somevalue) to send formatted variables to the firebug console.
Released under MIT open source license
Speaking of alternate options, from David Meagor post, you can also write traces to a file. Here is an example of how to write to files: https://web.archive.org/web/20210506122630/http://www.4guysfromrolla.com/webtech/040699-1.shtml
If you want, you can even put the trace subroutines in an include file and use that in all your pages when you need it.
Another solution that we are using is to put the tracing methods in a .Net assembly, register it as a COM then call it using CreateObject.
These options will let you keep your traces in a file that you can review later and share with other developers.
I personally use a mix of these approaches: I review log files, use breakpoints and even place from time to time a Response.Write.
One other thing: activate and review the IIS logs: they will often tell you on what line your page broke. You can read here how to enable or disable logs for classic ASP: https://technet.microsoft.com/en-us/library/hh831387.aspx.

Resources