我的CascadingDropDown可以在Localhost上运行,但随后会给出"Method Error 500"(方法错误500).当我把它放在我们的测试服务器上时 [英] My CascadingDropDown works on Localhost but then Gives "Method Error 500" when I put it on our testing server

查看:149
本文介绍了我的CascadingDropDown可以在Localhost上运行,但随后会给出"Method Error 500"(方法错误500).当我把它放在我们的测试服务器上时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发誓,我会在这里尽可能多地插入我的代码片段.我还用谷歌搜索了这个骗子.我真的对为什么发生上述情况感到迷惑.我有一个.asmx文件,例如:

I swear, I am putting as small a snippet of my code in here as I can. I have also Googled the heck out of this skanker. I am really befuddled as to why the above is happening. I have a .asmx files such as this:

<%@ WebService Language="C#" CodeBehind="MakeModelWebService.asmx.cs" Class="BSA.UI.Web.C8.TireAdvisor.MakeModelWebService" %>



因此,后面的代码是:



And the codebehind is thus:

<pre>    
    /// <summary>
    /// Summary description for MakeModelWebService
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.Web.Script.Services.ScriptService]
    public class MakeModelWebService : System.Web.Services.WebService
    {
        IAdvisorModelRepository advisorModelRepository = new AdvisorModelRepository();
        // TODO: TCL - Should Do - remove use of language and brand code from web service
        const string TESTLANGUAGE = "English";
        const string TESTBRANDCODE = "BR";
        [WebMethod]
        [ScriptMethod]
        public CascadingDropDownNameValue[] GetYears(string knownCategoryValues, string category)
        {
            try
            {
                var values = new List<CascadingDropDownNameValue>();
                foreach (string year in advisorModelRepository.GetYears(TESTLANGUAGE, TESTBRANDCODE))
                {
                    values.Add(new CascadingDropDownNameValue { name = year, value = year });
                }
                return values.ToArray();
            }
            catch (Exception ex)
            {
                File.WriteAllText(
                    Server.MapPath("~/TireAdvisor/ErrorLog.txt"),
                    ex.Message + "\r\n\r\n" + ex.Source + "\r\n\r\n" + ex.StackTrace);
                File.WriteAllText(
                    Server.MapPath("~/~/TireAdvisor/ErrorLog2.txt"),
                                        ex.InnerException.Message + "\r\n\r\n" + ex.InnerException.Source + "\r\n\r\n" + ex.InnerException.StackTrace);
                return null;
            }
        }
    }



没有错误日志写入服务器,因此未发生异常.这是我的ASPX中的级联下拉列表:



No error logs are written on the server, so an exception did not happen. Here is the cascading drop down in my ASPX:

<tr>
  <td>
    <cm:ContentLabel ID="ContentLabel4" runat="server" ContentTag="TS-Wizard-Year" Text="Select Year" />
  </td>
  <td>
      <asp:DropDownList ID="ddlYear" runat="server" AutoPostBack="false" Font-Names="Tahoma" />
      <cm:ContentLabel ID="lblYearRequired" runat="server" ContentTag="RequiredError" Visible="false"  Width="0px" />
      <!-- JSON Drop down. Set autopostback to false and remove onselected index. Remove asyc triggers -->
      <ajaxToolkit:CascadingDropDown ID="ccdYear" runat="server" TargetControlID="ddlYear" Category="Year"  ServicePath="MakeModelWebService.asmx" EnableViewState="true" />
  </td>
</tr>



因此,在级联下拉菜单中配置以下代码:



In the codebehind the cascading drop down is configured thus:

private void ConfigureCascadingDropDowns()
 {
     ccdYear.PromptText = ccdYear.EmptyText = DropDownTextDriver.GetChooseYearText(
         this.LanguageString);
     ccdMake.PromptText = ccdMake.EmptyText = DropDownTextDriver.GetChooseMakeText(
         this.LanguageString);
     ccdModel.PromptText = ccdModel.EmptyText = DropDownTextDriver.GetChooseModelText(
         this.LanguageString);
     ccdYear.PromptValue = ccdYear.EmptyValue = string.Empty;
     ccdMake.PromptValue = ccdMake.EmptyValue = string.Empty;
     ccdModel.PromptValue = ccdModel.EmptyValue = string.Empty;
     switch (UserState.SearchMode)
     {
         default:
             ccdYear.ServiceMethod = "GetYearsPageMethod";
             ccdYear.TargetControlID = ddlYear.ID;
             ccdMake.ServiceMethod = "GetMakes";
             ccdMake.TargetControlID = ddlMake.ID;
             ccdMake.ParentControlID = ddlYear.ID;
             ccdModel.ServiceMethod = "GetModelsForYearAndMake";
             ccdModel.ParentControlID = ddlMake.ID;
             ccdModel.TargetControlID = ddlModel.ID;
             break;
         case QuickSearchMode.MakeOnly:
         case QuickSearchMode.MakeAndModelOnly:
             ccdMake.ParentControlID = string.Empty;
             ccdMake.ServiceMethod = "GetAllMakes";
             ccdMake.TargetControlID = ddlMake.ID;
             ccdModel.ParentControlID = ddlMake.ID;
             ccdModel.ServiceMethod = "GetModelsByMake";
             ccdModel.TargetControlID = ddlModel.ID;
             ccdYear.ParentControlID = ddlModel.ID;
             ccdYear.ServiceMethod = "GetYearsByMakeAndModel";
             ccdYear.TargetControlID = ddlYear.ID;
             break;
     }
 }



显示下拉菜单时,它应显示选择年份:"项(的值),然后显示2011-1983年.它显示选择年份:",然后显示[方法错误500].

我究竟做错了什么?如何配置我们的服务器以允许此操作?

我尝试添加文本



When the drop down displays, it should display a "Choose Year:" item (the value of the ) and then the years 2011-1983. It displays "Choose Year:" and then [Method Error 500].

What am I doing wrong? How does our server need to be configured to allow this?

I''ve tried adding the text

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



到web.config,但这会使整个站点中断,并显示500-内部服务器错误.我们做错了什么?我们已经尝试了一切,并且已经进行了一周.

任何提示将不胜感激.



to the web.config but this makes the whole site break with a 500 - Internal Server Error. What are we doing wrong? We''ve tried everything and this has been going on for a week.

Any hints would be greatly appreciated.

推荐答案

到目前为止,您所做的事情对我来说是一件好事,但一件事情除外.您没有提供使用者应用程序的web.config部分.在部署服务器中,您可能必须更改Web服务定位器服务器的url .这是这样做的一种方法.
The things you done so far is fine for me except one thing. You didn''t provide the web.config section part of the consumer application. In deployment server you may have to change the url for the web service locator server. Here is one way to do so.
<system.serviceModel>
   <bindings>
     <basicHttpBinding>
       <binding name="Service1Soap" closeTimeout="00:01:00" openTimeout="00:01:00"

         receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"

         bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"

         maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"

         messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"

         useDefaultWebProxy="true">
         <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"

           maxBytesPerRead="4096" maxNameTableCharCount="16384" />
         <security mode="None">
           <transport clientCredentialType="None" proxyCredentialType="None"

             realm="" />
           <message clientCredentialType="UserName" algorithmSuite="Default" />
         </security>
       </binding>
     </basicHttpBinding>
   </bindings>
   <client>
     <endpoint address="http://localhost:65106/Service1.asmx" binding="basicHttpBinding"

       bindingConfiguration="Service1Soap" contract="ServiceReference1.Service1Soap"

       name="Service1Soap" />
   </client>
 </system.serviceModel>


因此,在endpoint 部分中,address 指向localhost:65106.您必须使用实际服务url指向合格的服务器名称.即http://testserver1/Service1.asmx

希望对您有帮助.


So in the endpoint section the address is pointing to localhost:65106. You have to point to the qualified server name with the actual service url. i.e http://testserver1/Service1.asmx

Hope this will help you well.


这篇关于我的CascadingDropDown可以在Localhost上运行,但随后会给出"Method Error 500"(方法错误500).当我把它放在我们的测试服务器上时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆