Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you debug a single ASPX file?

Tags:

c#

asp.net

How do you debug a single ASPX file?

I am somewhat new to ASPX files, but I am not new to C#.

I figured that all asp.net c# projects were run on the server as compiled code. And so there was some sort of binary file somewhere somehow or maybe a XAP file like they have with silverlight.

But it seems that this is not the case. it seems that, sometimes, you can have an ASPX file along with the code-behing C Sharp file and it runs just like a PHP file. For starters, is that right? Am I right so far?

Now, if I was the owner of both the ASPX file and the CSHARP code-behind file, how would I go about debugging it in Visual Studio?

How do I run the code?

My point is that there is no project to load. There is only a file.

After setting a break point, there is nothing to run. I have tried attaching to the browser that has the aspx code loaded but then the breakpoints become inactive.

the file is https://www.seattleu.edu/admission/nonMatricLander.aspx

and out on the server there is just the aspx file and the accompanying .cs file

That is all there is. There is no solution file, there is no default.aspx file there is nothing else in the that directory apart from other .aspx files and aspx.cs files.

If it was a web form, there would be a project file and and or a solution file. There would be something compiled, right? There is nothing like that. there are no dll files

like image 939
xarzu Avatar asked Jul 08 '26 22:07

xarzu


1 Answers

Assuming you've already got ASPX page to render on local IIS server (i.e. by dropping to folder for default site).

In Visual Studio

  • Open page (from localhost:....) in browser of your choice
  • Debugger -> Attach To process
  • See if w3wp is in the list, if not check "show from all users" checkbox, may need to run VS as admin (or user that have debug privileges)
  • Attach to w3wp (make sure to pick correct .Net version if necessary)
  • Open ASPX/ASPX.cs from and set breakpoints
  • Refresh page in browser to hit breakpoints

Note: creating one of Web projects would be easier as you will be able to use local server provided by VS and easier overall experience.

like image 80
Alexei Levenkov Avatar answered Jul 10 '26 11:07

Alexei Levenkov