Debug aspx / cs scripts with no VS2017 project - asp.net

Someone's handed me a crashing aspx / .cs script to debug.
Any idea how to set up a VS2017 project to debug it?
I've tried using the wizard, Visual C#, asp.net
This works OK for one set of pages on the site, Default.aspx and Default.aspc.cs
When I add the page I want to debug I get loads of compilation errors in the cs file, referring to objects in the aspx
The name 'Chart1' does not exist in the current context
and one reference I can't see how to sort out
Error CS0012 The type 'Package' is defined in an assembly that is not referenced. You must add a reference to assembly 'WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
Am I going about this the right way?

VS2017 - File -> Open -> Website
browse to your local source folder and press OK
Right click on the aspx you want to debug. Choose 'Set As Start Page'
Now run the project.

Related

Does visual studio includes only aspx.cs files in dll which are having same namespace of project?

I am using visual studio 2012. I have created a directory named "Handler" inside my project and added an aspx file along with .cs file (both downloaded from a third party tool) to it. All code is working fine.
Now, I have published project to another directory. In published directory I have marked that the in side "Handler" folder aspx page is there but not the .cs page.
Now, when ever I am requesting the aspx page inside "Handler", I am getting error 404 xxxx.aspx page not found. Now, if I am coping the path and hit the url for that page then I am getting error that xxxx.aspx.cs file not found.
As per my best knowledge, whenever we build the project, all the code will build to dll in bin folder. Then why this file is required .cs file?
Thanks.
This will depend on the attributes of the #Page directive of your aspx page
I guess your third party page #page directive holds a CodeFile attribute.
CodeFile attribute states that, even though the .aspx.cs gets compiled (let's say it just gets checked) in Visual Studio, the result of the compilation will not be put in the dll resulting of the build.
The .aspx.cs will be compiled, along with the .aspx upon first invocation.
This allows to edit your deployed aspx.cs and have the result available immediately (which can be seen as handy, or risky)
As per my best knowledge, whenever we build the project, all the code
will build to dll in bin folder. Then why this file is required .cs
file?
This is the case when being in the default case, having a CodeBehind attribute in the page directive,instead of a CodeFile attribute
See CodeBehind and CodeFile attributes in documentation for #Page element
Note that you can use CodeFile attribute in Web Application Projects. I do it all the time.

The file '/mypage.aspx' has not been pre-compiled, and cannot be requested

I have a VS 2005 web site that I publish using "Publish Web Site", and I clear all the three checkboxes. I modify the mypage.aspx file and publish web site.
Then, I replace that file with the old one and I get this error:
The file '/mypage.aspx' has not been pre-compiled, and cannot be requested.
How can I replace that file?
This error appears also when a reference is specified in your web.config file and deployment folder/site does not contain these dlls (or the specific version you specified in the web.config) installed in the system (GAC) or bin folder does not contain them.
Example:
<add assembly="Namespace.BlaBla, Version=1.2.3.4, Culture=neutral,
PublicKeyToken=7aff3896eb354e31"/>
If you deploy version 1.2.3.5 of that DLL you'll get the (misleading) error message.
May be in server c drive is out of space

The assembly AjaxControlToolkit does not contain a Web resource that has the name 'jquery'

I have a project in ASP.Net 4.5 Web Forms. When I run the project locally, it works fine. But when i deploy it I get this error:
The assembly 'AjaxControlToolkit, Version=4.5.7.429, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e' does not contain a Web resource that has the name 'jquery'. Make sure that the resource name is spelled correctly.
I have tried to remove "Microsoft.AspNet.ScriptManager.MSAjax 4.5.6", but it still doesn't work.
I had this same problem today, when I point to localhost:port (or wherever is your case) the jquery error is shown. BUT when I point to localhost:port/Index.aspx (or your main page), the error doesn't show up. So I can imagine it may be due to the default page for the proyect not being set properly.

Ajax NumericUpDownExtender error

I am getting this error when trying to use the numericupdown control:
Assembly 'AjaxControlToolkit, Version=3.0.30512.20315,
Culture=neutral, PublicKeyToken=28f01b0e84b6d53e' contains a Web
resource with name
'AjaxControlToolkit.NumericUpDown.NumericUpDownBehavior.debug.js', but
does not contain an embedded resource with name
'AjaxControlToolkit.NumericUpDown.NumericUpDownBehavior.debug.js'.
I have researched this and have found that this problem arises because the source code for the AJAXToolkit calls the file 'NumericUpDownBehavior.debug..js'. The only solution I have seen is this one:
Download the ajax control toolkit with the source code. Go to the folder
"AjaxControlToolkit\NumericUpDown\" and there's a file there named
"NumericUpDownBehavior.debug..js". Rename it to "NumericUpDownBehavior.debug.js".
After this open the "AjaxControlToolkt" project in Visual studio and choose "Show All
Files" in Solution Explorer". Exclude from the project the file with
the double dots (.debug..js) and include the correct one. Right click
on the .js file and choose "Properties". From there Choose the Build
Action "Embedded Resource". Compile it and add the resulting dll to to
your projects where you are using ajax (Replace the dll's).
I have tried this but I must have done it wrong because it did not work. Can anyone provide a more detailed solution to this problem?
Thanks!

Installing a ASP.NET application

Ok, this has got to be a super simple problem. I just can't seem to find the answer anywhere. First - I'm not a web developer of any kind, I'm an old school c programmer - so don't flame me for what's probably something quite trivial :)
I need to write a small proof-of-concept web app using ASP.NET. My first attempt here is to create a "Hello World!" app. So I opened up Visual Studio, and made a new web application. I have my Default.aspx file that calls a C# function that is inside the helloworld.dll created automatically by Visual Studio.
I installed IIS on my local machine and created a virtual directory in the wwwroot subdirectory. I put the Default.aspx and helloworld.dll in that directory. Now when I browse to that page I see the following.
Server Error in '/test' Application.
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: Could not load type 'HelloWorld._Default'.
Source Error:
Line 1: <%# Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="HelloWorld._Default" %>
Line 2:
Line 3: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Source File: /test/default.aspx Line: 1
Obviously, IIS doesn't know where to look for the .dll or anything like that. I just don't know how to register the .dll with IIS (or whoever manages that stuff in .net) so that it can find the functions it need.
Can someone let me know how to "install" an ASP.NET application on IIS?
Your best bet is to use 'Publish website' from the Visual Studio Solution Explorer.
Chris Lively adds:
Just a minor add: Publish Website can
be found by Right Clicking on the
project name. The command will be
named "Publish..."
You do not need to move the files to the wwwroot directory manually. A virtual directory in IIS points to any folder in the file system to look for the appliction.
Follow these steps if you are using IIS6:
Open IIS
Under "Web Sites", right-click "Default Web Site"
Select "New"
Select "Virtual Directory"
Type in a name for your new app.
Select the path of your application. By default this is usually something like C:\Your Documents\Visual Stuido 2008\Projects\Your Project Name
Leave the acess permissions as they are.
Click Finish
If you browse to "http://localhost/TheNameOfTheVirtualDirectory/Default.aspx" you should be able to view the page.
I would recommend the solution of Rich B. And something else... DLLs are in a folder called "bin". Not at the root of the folder.

Resources