我在下拉列表中收到错误Method error 500.
我不知道它有什么问题。昨天我通过对此进行研究浪费了我一整天。我尝试了各种解决方案,但它有效。
代码:
[WebMethod]
[System.Web.Script.Services.ScriptMethod]
public static CascadingDropDownNameValue[] GetDropDownContentsPageMethod(string knownCategoryValues,string category)
{
return new categorylist().GetDropDownContents(knownCategoryValues, category);
}
的.aspx:
<div class="row">
<div class="form-group">
<div class="col-sm-2"></div>
<label class="control-label col-sm-2" for="Category">Category:</label>
<div class="col-sm-8">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:DropDownList ID="DropDownList1" runat="server" EnableViewState="False"
AppendDataBoundItems="True" CssClass="form-control" style="width:50%;">
</asp:DropDownList>
<ajaxToolkit:CascadingDropDown ID="CascadingDropDown1" runat="server" TargetControlID="DropDownList1"
PromptText="Please select" Category="category1" ServicePath="categorylist.asmx"
ServiceMethod="GetDropDownContents" LoadingText="[Loading sections…]">
</ajaxToolkit:CascadingDropDown>
<asp:RequiredFieldValidator ID="RequiredFieldValidator11" runat="server" ErrorMessage="* Select Category"
ControlToValidate="DropDownList1"></asp:RequiredFieldValidator>
</div>
</div>
</div>
categorylist.asmx:
<%@ WebService Language="C#" CodeBehind="~/App_Code/categorylist.cs" Class="categorylist" %>
categorylist.cs:
using System;
using System.Web;
using System.Collections;
using System.Collections.Specialized;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml;
/// <summary>
/// Helper web service for CascadingDropDown sample
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.Web.Script.Services.ScriptService()]
public class categorylist : System.Web.Services.WebService
{
// Member variables
private static XmlDocument _document;
private static object _lock = new object();
// we make these public statics just so we can call them from externally for the
// page method call
//
public static XmlDocument Document
{
get
{
lock (_lock)
{
if (_document == null)
{
// Read XML data from disk
_document = new XmlDocument();
_document.Load(HttpContext.Current.Server.MapPath("~/App_Data/categorydl.xml"));
}
}
return _document;
}
}
public static string[] Hierarchy
{
get
{
return new string[] { "category1" };
}
}
/// <summary>
/// Constructor to initialize members
/// </summary>
public categorylist()
{
}
/// <summary>
/// Helper web service method
/// </summary>
/// <param name="knownCategoryValues">private storage format string</param>
/// <param name="category">category of DropDownList to populate</param>
/// <returns>list of content items</returns>
[WebMethod]
public AjaxControlToolkit.CascadingDropDownNameValue[] GetDropDownContents(string knownCategoryValues, string category)
{
// Get a dictionary of known category/value pairs
StringDictionary knownCategoryValuesDictionary = AjaxControlToolkit.CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues);
// Perform a simple query against the data document
return AjaxControlToolkit.CascadingDropDown.QuerySimpleCascadingDropDownDocument(Document, Hierarchy, knownCategoryValuesDictionary, category);
}
}
的Web.config:
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<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">
</sectionGroup>
</sectionGroup>
</configSections>
<system.web>
<compilation debug="true" targetFramework="4.5.2" />
<!--<compilation debug="true"></compilation>-->
<httpRuntime targetFramework="4.5.2" />
<!--<customErrors mode="Off"/>-->
<pages>
<controls>
<add namespace="AjaxControlToolkit" assembly="AjaxControlToolkit" tagPrefix="ajaxToolkit"/>
<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</controls>
</pages>
<httpHandlers>
<remove verb="*" path="*.asmx"/>
<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=4.5.2.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=4.5.2.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false"/>
<add verb="GET" path="CaptchaImage.axd" type="MSCaptcha.CaptchaImageHandler, MSCaptcha"/>
</httpHandlers>
</system.web>
<appSettings>
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
</appSettings>
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules>
<remove name="ScriptModule"/>
<add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</modules>
<handlers>
<add name="MSCaptcha" verb="GET" path="CaptchaImage.axd" type="MSCaptcha.CaptchaImageHandler, MSCaptcha"/>
<remove name="WebServiceHandlerFactory-Integrated"/>
<remove name="ScriptHandlerFactory"/>
<remove name="ScriptHandlerFactoryAppServices"/>
<remove name="ScriptResource"/>
<add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</handlers>
<httpErrors>
<error statusCode="400" path="C:\inetpub\vhosts\dubaiexporters.com\error_docs\bad_request.html"/>
<remove statusCode="401" subStatusCode="-1"/>
<error statusCode="401" path="C:\inetpub\vhosts\dubaiexporters.com\error_docs\unauthorized.html"/>
<remove statusCode="403" subStatusCode="-1"/>
<error statusCode="403" path="C:\inetpub\vhosts\dubaiexporters.com\error_docs\forbidden.html"/>
<remove statusCode="404" subStatusCode="-1"/>
<error statusCode="404" path="C:\inetpub\vhosts\dubaiexporters.com\error_docs\not_found.html"/>
<remove statusCode="405" subStatusCode="-1"/>
<error statusCode="405" path="C:\inetpub\vhosts\dubaiexporters.com\error_docs\method_not_allowed.html"/>
<remove statusCode="406" subStatusCode="-1"/>
<error statusCode="406" path="C:\inetpub\vhosts\dubaiexporters.com\error_docs\not_acceptable.html"/>
<error statusCode="407" path="C:\inetpub\vhosts\dubaiexporters.com\error_docs\proxy_authentication_required.html"/>
<remove statusCode="412" subStatusCode="-1"/>
<error statusCode="412" path="C:\inetpub\vhosts\dubaiexporters.com\error_docs\precondition_failed.html"/>
<error statusCode="414" path="C:\inetpub\vhosts\dubaiexporters.com\error_docs\request-uri_too_long.html"/>
<error statusCode="415" path="C:\inetpub\vhosts\dubaiexporters.com\error_docs\unsupported_media_type.html"/>
<remove statusCode="500" subStatusCode="-1"/>
<error statusCode="500" path="C:\inetpub\vhosts\dubaiexporters.com\error_docs\internal_server_error.html"/>
<remove statusCode="501" subStatusCode="-1"/>
<error statusCode="501" path="C:\inetpub\vhosts\dubaiexporters.com\error_docs\not_implemented.html"/>
<remove statusCode="502" subStatusCode="-1"/>
<error statusCode="502" path="C:\inetpub\vhosts\dubaiexporters.com\error_docs\bad_gateway.html"/>
</httpErrors>
</system.webServer>
</configuration>
导致错误Method error 500
的原因是什么?
我正在将现有网站转换为响应式网站。它在现有网站(框架3.5)中工作正常。我正在转换为响应式网站(使用框架4.5.2)?
这是一个问题吗?
我们将非常感谢您的帮助。