None of my “code behind” code is being called

前端 未结 9 1920
予麋鹿
予麋鹿 2021-02-08 00:40

I have just created an ASP.NET C# project and a virtual directory for it in IIS in (as far as I know) the normal way, but I am seeing very strange behavior that I have never see

相关标签:
9条回答
  • 2021-02-08 01:13

    I suspect your Page declaration (<%@ Page ... %>) in the apsx file is wrong. Look at ClassName and CodeBehind attributes and make sure they match your .cs file.

    0 讨论(0)
  • 2021-02-08 01:18

    I learned this the hard way and it might be your issue.

    Make sure the bin folder is in the root of the website in IIS.

    I had www.mysite.com/myapp/bin and that didn't work, I needed to have the dlls in www.mysite.com/bin, even if my pages were all inside www.mysite.com/myapp (In my case I had Wordpress running in the root with PHP and ASP.NET stuff in a subfolder for certain pages)

    (What made it worse to track down for me is that there was a bin folder in the root already from a previous deploy and I was updating the site and wondering why my code-behind changes weren't taking effect)

    EDIT: Found out how to avoid putting the bin folder in the website root. In IIS, if you right-click on your application folder in the website, there's an option to "Convert to application" (at least there is in IIS 7.5 not sure about older versions). After doing that, that folder will be able to use it's own bin and web.config

    EDIT2: Instructions for IIS 6 and 7: http://www.banmanpro.com/support2/appstartpoint.asp

    0 讨论(0)
  • 2021-02-08 01:18

    Remove the following page directive from your HTML view, build the website and try to load the page in the browser.

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="Drawings2.WebForm1" %>
    
    0 讨论(0)
提交回复
热议问题