I can not believe I have to ask this, but here I am!
Here is all I have done:
- Visual Studio 2013 - Create New ASP.NET Web Application (Empty). Saved it as MyWebApp.
- Once the project was created, I right-clicked and added a new item: Web Form Saved it as index.aspx
- In the designer, added a button.
Created a Click event for this button that looks like:
protected void Button1_Click(object sender, EventArgs e) { string myStringVariable = "foo"; ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + myStringVariable + "');", true); }
Done. That's it. Can't get any simpler.
So then I built it. And published it using Visual Studio 2013. I chose the Publish method of File System and a local location of C:\inetpub\wwwroot.
Now, I did this locally, in my VM, just to see what files it would place. And as I thought, in wwwroot:
- It created a bin folder and placed MyWebApp.dll in this folder.
- It placed a web.config
- It placed index.aspx.
So, now, let's go to my actual real web server! I mean, I can place static html files there right now, and view them from my browser. It works!
So I go to the default website (c:\inetpub\wwwroot), created a folder called ASP, and placed those files in it (index.aspx, web.config, bin folder with dll).
When I run it using (I'm on the server): http://localhost/ASP/index.aspx I continually get this parser error:
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: The file '/ASP/index.aspx.cs' does not exist.
Source Error:
Line 1: <%@ Page Language="C#" AutoEventWireup="true" CodeFile="index.aspx.cs" Inherits="MyWebApp.index" %> Line 2: Line 3:
Source File: /ASP/index.aspx Line: 1
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.6.1086.0
(I have switched between CodeFile and CodeBehind - based on some googling here, neither works).
No matter what I do, I can't get index.aspx to "find/see" index.aspx.cs that's inside the dll. Is there some configuration step I'm missing? I just don't get it.
Thanks.
EDIT: To be clear, I believe it's because I put it in a subfolder. It seems to work if I put those same files just in wwwroot, instead of the subfolder. I just added that to the title, because as soon as I pressed submit on this question - I realized, maybe it's because it's in this subfolder! Isn't that the way this always works? Ask for help, and the process of writing it up gives you clarity? :)
EDIT: Arrgh! The other tid-bit of info I left out was that I was trying this on Port 81. I had created a 2nd Site (IIS) and binded it to port 81 (and yes I'm including that in my URL). And I was playing around there. And I had even thought to make it an Application (the subfolder). But it just doesn't work there. Only under my Default Web Site. I must be missing some type of configuration information.