星期一下午,我正在开发一个 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有关吗?