周一下午,我正在开发一个Web服务,能够在浏览器中请求.asmx文件,并获得了可用方法的菜单,并且能够从浏览器中调用它们,没有任何问题。星期二到来,每次我访问它时,都会收到一个“对象移动到此处”消息,该消息链接到一个不存在的login.aspx页面。
这是.asmx.cs文件:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Script.Services;
using System.Data.SqlClient;
namespace LegacyReports
{
/// <summary>
/// Summary description for Example
/// </summary>
[WebService(Namespace = "http://company.com/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
//[System.Web.Script.Services.ScriptService]
public class Example : System.Web.Services.WebService
{
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json, UseHttpGet = false)]
public List<ExampleData> ExampleDataSet()
{
Context.Database db = new Context.Database();
String sql = @"SELECT TOP 10 * FROM sometable";
SqlDataReader reader = db.ExecuteReader(sql);
List<ExampleData> data = new List<ExampleData>();
while (reader.Read())
{
int a = Convert.ToInt32(reader["somecolumn"]);
String b = (String)reader["anothercolumn"] + " " + (String)reader["someotherrandomcolumn"];
data.Add(new ExampleData() { a = a, b = b });
}
return data;
}
}
public class ExampleData
{
public int a { get; set; }
public String b { get; set; }
}
}
我只是不确定为什么它会在某一天起作用然后在第二天停止。它可能是IIS的东西吗?