1

我使用asp.net 5 年以上。但现在我面临一个奇怪的问题。当我尝试从我创建的包含 asp:button、asp:textbox 等的表单发送电子邮件时,在代码页中它总是告诉 IsPostBack false。即使我单击发送邮件按钮(asp.net 按钮)。我无法理解有什么问题。

web.config 文件中是否需要回发任何东西?

测试页面http://buyerrs.com/Test.aspx

确定它在测试页面中没有问题。因为它是非常普通的页面,在 vb 中只有一个按钮和代码。缓存、urlrewrite 或 web.config 中的某处出现问题。但我不明白在哪里?

    <?xml version="1.0" encoding="UTF-8"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">

  <configSections>
    <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
      <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
        <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
        <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
          <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere" />
          <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
          <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
          <section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />
        </sectionGroup>
      </sectionGroup>
    </sectionGroup>
  </configSections>

   <system.web>

     <httpHandlers>
       <remove verb="*" path="*.asmx"/>
       <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
       <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
       <add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false"/>
     </httpHandlers>

      <httpModules>
        <add name="vchHttpModule" type="VchBaseSite.vchHttpModule" />
      </httpModules>

      <!-- need to increase the size of the permitted upload size -->
      <httpRuntime maxRequestLength="20480" />

      <!-- set compilation debug="false" for running application -->
      <compilation debug="true" strict="false" explicit="true" defaultLanguage="vb">
         <assemblies>
            <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
            <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
            <add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
           <add assembly="System.Data.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
         </assemblies>
      </compilation>

      <trace enabled="false" pageOutput="true" localOnly="true" />

      <sessionState mode="Off" />

      <!-- customErrors mode="On|Off|RemoteOnly" -->
      <customErrors mode="Off">
         <error statusCode="404" redirect="404.aspx" />
         <error statusCode="500" redirect="500.html" />
      </customErrors>

      <pages enableViewState="false">
         <namespaces>
            <clear />
            <add namespace="System" />
            <add namespace="System.Collections" />
            <add namespace="System.Collections.Generic" />
            <add namespace="System.Configuration" />
            <add namespace="System.IO" />
            <add namespace="System.IO.Compression" />
            <add namespace="System.Linq" />
            <add namespace="System.Text" />
            <add namespace="System.Web" />
            <add namespace="System.Web.Security" />
            <add namespace="System.Web.UI.WebControls" />
            <add namespace="System.Web.UI" />
            <add namespace="System.Xml.Linq" />
         </namespaces>
         <controls>
           <add tagPrefix="vch" namespace="VchBaseSite" assembly="VchBaseSite" />
         </controls>
      </pages>

      <!-- set code access security trust level - this is generally set in the machine.config
      <trust level="Medium" originUrl=".*" />-->

      <machineKey
        validationKey="CF19275EF5E6206C1E289BAC5240240548B1015A2A68137B411A08E2F2BFE55223C42B1FECB10B6A660CD00DEE02F005959D7E4929660A81CF756E69BF3F56C8"
        decryptionKey="A32BD7AEDF208B05B85828E644774810C928F5F76A6AD0A50F982EBD235634A3"
        validation="SHA1" decryption="AES"
      />

      <authentication mode="None" />

      <roleManager>
          <providers>
              <clear />
          </providers>
      </roleManager>

   </system.web>

   <system.codedom>
      <compilers>
         <compiler language="c#;cs;csharp" extension=".cs" warningLevel="4" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
            <providerOption name="CompilerVersion" value="v3.5" />
            <providerOption name="WarnAsError" value="false" />
         </compiler>
         <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" warningLevel="4" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
            <providerOption name="CompilerVersion" value="v3.5" />
            <providerOption name="OptionInfer" value="true" />
            <providerOption name="WarnAsError" value="false" />
         </compiler>
      </compilers>
   </system.codedom>

   <!--
     The system.webServer section is required for running ASP.NET AJAX under Internet
     Information Services 7.0.  It is not necessary for previous version of IIS.
    -->
   <system.webServer>
      <validation validateIntegratedModeConfiguration="false" />


<!--
      <defaultDocument>
         <files>
            <clear />
            <add value="default.aspx" />

          <add value="Default.aspx" /> 
            <add value="default.htm" />
            <add value="Default.htm" />
         </files>
      </defaultDocument> -->
   </system.webServer>

   <runtime>
      <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1" appliesTo="v2.0.50727">
         <dependentAssembly>
            <assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35" />
            <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0" />
         </dependentAssembly>
         <dependentAssembly>
            <assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35" />
            <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0" />
         </dependentAssembly>
      </assemblyBinding>

      <connectionStrings>
        <remove name="LocalSqlServer" />
      </connectionStrings>
   </runtime>

</configuration>

这是 web.config 文件

最后我找到了错误上升的地方。本网站代码基于此http://www.datafeedscripts.net/default.aspx软件。他们正在使用三个 dll 文件(vchsite.dll、vchLicense.dll、vchbasesite.dll)并在下面有一个 httpmodule 代码

<httpModules>
    <add name="vchHttpModule" type="VchBaseSite.vchHttpModule" />

当我排除该 dll 并从 web.config 文件回发中删除 httpmodule 行时,工作正常。所以这是错误的。他们在他们的 Dll 文件或 httpmodule 中做错了什么。

但仍然无法理解什么是错误。是否有机会控制 dll 文件的回发操作?

4

6 回答 6

2

我知道这有点旧,但我会检查 HttpModule。vchHttpModule 可能会劫持请求并使 IsPostBack 无效。

于 2014-02-01T01:51:18.873 回答
0

回发后查看您的页面源,我看到:

IsPostBack : False on 2/10/2012 3:50:06 PM

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
...

到底是如何将“IsPostBack:False..”放在您的 DOCTYPE 之前的简介。检查您的 Protected Sub Page_Load 事件处理程序并确保它是正确的语法等,因为它似乎可能在它应该之前触发,因此没有获得 IsPostBack 的正确状态。

于 2012-02-10T20:53:09.243 回答
0

我不明白一个想法。您将 AutoEventWireup 设置为 false,这意味着未调用 PageLoad,但您说这被称为...有线...也许加载了其他一些类,这里混杂了一些东西。

AutoEventWireup="false"

你能把它变成真的看看结果吗?

于 2012-02-10T20:55:29.413 回答
0

您没有要处理的单击事件,而是作为提交按钮工作,不会生成回发。

http://www.w3schools.com/aspnet/prop_webcontrol_button_usesubmitbehavior.asp

关闭提交行为。

于 2012-02-10T20:41:12.563 回答
0

我查看了 IsPostBack MS 实现,也可以在此处找到

通过反射,您可以“读取”这些 if 语句中使用的每个值。
可惜我用的是C#,希望你能翻译成VB

protected void Page_Load(object sender, EventArgs e)
        {
            Response.Write(IsPostBack.ToString() + " " + DateTime.Now.ToShortDateString());
            Response.Write("<br />");
            
            //return this._requestValueCollection != null && (this._isCrossPagePostBack 
            //|| (!this._pageFlags[8] && (this.Context.ServerExecuteDepth <= 0 
            //        || (this.Context.Handler != null && !(base.GetType() != this.Context.Handler.GetType()))) && !this._fPageLayoutChanged));

            var pType = this.GetType();
            while (pType.Name != "Page")
                pType = pType.BaseType;
            var _requestValueCollection = pType.GetField("_requestValueCollection", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(this);
            Response.Write("_requestValueCollection: " + (_requestValueCollection != null).ToString());
            Response.Write("<br />");

            var _isCrossPagePostBack = pType.GetField("_isCrossPagePostBack", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(this);
            Response.Write("_isCrossPagePostBack: " + _isCrossPagePostBack);
            Response.Write("<br />");

            var _pageFlags = pType.GetField("_pageFlags", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(this);
            Response.Write("_pageFlags: " + (((int)_pageFlags.GetType().GetField("data", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(_pageFlags) & 8) == 8));
            Response.Write("<br />");
            //SimpleBitVetctor32
            var cType = this.Context.GetType();
            var ServerExecuteDepth = cType.GetProperty("ServerExecuteDepth", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(this.Context, null);
            Response.Write("ServerExecuteDepth: " + ServerExecuteDepth.ToString());
            Response.Write("<br />");

            Response.Write("Context_Handler: " + (this.Context.Handler != null));
            Response.Write("<br />");


            var _fPageLayoutChanged = pType.GetField("_fPageLayoutChanged", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(this);
            Response.Write("_fPageLayoutChanged: " + _fPageLayoutChanged.ToString());
            Response.Write("<br />");

            Response.Write("base.GetType() != this.Context.Handler.GetType())) " + (base.GetType() != this.Context.Handler.GetType()));
        }

C# 到 VB

更新

由于您也无法获取控件的值,因此我怀疑 _requestValueCollection 为空。_requestValueCollection 是发布值和查询字符串值的集合。这仍然不能解决问题..

于 2012-02-10T22:14:16.963 回答
0

尝试在 Page 标记中将 AutoEventWireup 设置为 true。

于 2012-02-10T21:24:11.763 回答