尝试通过代码加载外部asp.mvc网站时的内部服务器


Internal server when trying to load external asp.mvc website through code

我正试图帮助一位有问题的同事。这意味着我没有所有可用的调试信息,但我想也许这里有人可以引导我们朝着正确的方向前进。

正如标题中所述,他正试图通过代码加载外部网站的html。事实上,他正在使用cUrl。我还使用cUrl(php)、file_get_contents(php)和wget(terminal)以及WebClient和HttpWebRequest(c#)进行了测试。结果是一条内部服务器错误消息。

[NullReferenceException: Object reference not set to an instance of an object.]
Innsyn.Controllers.BaseController.ExecuteCore() +673
System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +334
System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +61
System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +19
System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +53
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +468
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +374

正如你所看到的,他试图加载的网站是一个asp.mvc应用程序:http://einnsyn.harstad.kommune.no/einnsyn

使用浏览器查看网站时,网站运行良好。

您需要提供http标头。使用浏览器插件查看在使用浏览器时发送到网站的标题,然后在工具中复制。我在eInnsyn上使用了这种方法来获取wget的数据。