简体   繁体   English

(500)C#和Web Dev 2008 Express的内部服务器错误

[英](500) Internal Server Error with C# and Web Dev 2008 Express

The code below is generic, found in a variety of places, including a book I have. 下面的代码是通用的,可以在很多地方找到,包括我所拥有的书。 I have used it as a base for a working program in VS 2005. Now I've resurrected it with my current Visual Web Developer 2008 Express Edition and I seem to have problems connecting it to my default development server (I don't have IIS on my XP). 我已将其用作VS 2005中工作程序的基础。现在,我已经用当前的Visual Web Developer 2008 Express Edition恢复了它,而且似乎无法将其连接到默认开发服务器(我没有IIS)在我的XP上)。 The error is: (500) Internal Server Error. 该错误是:(500)内部服务器错误。 Is this saying what I thought it did (above) or something else, and how do I solve this problem? 这是在说我认为(上面)做了什么,还是在解决其他问题?

using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Net;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text.RegularExpressions;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string strResult = "";
        string url = "http://weather.unisys.com";
        WebResponse objResponse;
        WebRequest objRequest;

        try
        {
            objRequest = System.Net.HttpWebRequest.Create(url);
        }
        catch
        {
            objRequest = System.Net.HttpWebRequest.Create("http://"+ url);
        }
        objResponse = objRequest.GetResponse();

        using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()))
        {
            strResult = sr.ReadToEnd();
            sr.Close();
        }
    }
}

I've noticed that your URL is " http://weather.unisys.com ", but when you're creating the new web request you're doing "http://" + URL, which will result in http://http://weather.unysis.com . 我注意到您的URL是“ http://weather.unisys.com ”,但是当您创建新的Web请求时,您正在使用“ http://” + URL,这将导致http:/ /http://weather.unysis.com Could this be the issue, maybe? 可能是这个问题吗?

我不再使用ASP.NET,但是我很确定当项目文件夹缺少某些特权时,新的ASP.NET项目会出现500个错误(您必须为此添加一些系统用户的权限)文件夹“ .NET”之类的东西?我不太记得用户名,但是在与.NET或Web连接的用户名中它很明显)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM