1

I can not believe I have to ask this, but here I am!

Here is all I have done:

  1. Visual Studio 2013 - Create New ASP.NET Web Application (Empty). Saved it as MyWebApp.
  2. Once the project was created, I right-clicked and added a new item: Web Form Saved it as index.aspx
  3. In the designer, added a button.
  4. 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:

  1. It created a bin folder and placed MyWebApp.dll in this folder.
  2. It placed a web.config
  3. 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.

JustLooking
  • 2,405
  • 4
  • 28
  • 38
  • What version of IIS are you running? What's the .Net version on the app pool for the website? – Stinky Towel May 08 '17 at 18:55
  • 1
    See [Run an ASP.NET website in a subfolder](http://stackoverflow.com/questions/1516041/run-an-asp-net-website-in-a-subfolder). – Dustin Kingen May 08 '17 at 18:58
  • this is a sign that the asp.net runtime attempts to compile from page source on startup. must be caused by either website/web application or codefile/codebehind. In your case, [CodeFile is wrong and CodeBehind would be correct](http://stackoverflow.com/a/954873/1132334). – Cee McSharpface May 08 '17 at 18:58
  • Well, it's the DefaultAppPool associated with DefaultWebSite. So everything is as it was on install. .NET CLR Version v4.0.30319. Integrated pipeline mode. The server is Windows Server 2012 R2 (64 bit). I should be more clear that it seems to work when it's in the Default WebSite (wwwroot), but as I mentioned, I put it in a folder called ASP under wwwroot. – JustLooking May 08 '17 at 18:59
  • @dlatikay - I've tried both codefile and codebehind. I think it's because I put it in a subfolder. I'm about to check out Romoku's link – JustLooking May 08 '17 at 19:00
  • It's a combination of subfolder and being on port 81. Did I not set up this IIS Site correctly? – JustLooking May 08 '17 at 19:33

0 Answers0