开发者

(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). The error is: (500) Internal Server Error. 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. Could this be the issue, maybe?


I don't use ASP.NET anymore but I'm pretty sure that 500 errors were pretty common with new ASP.NET projects when there was some privileges missing for project's folder (you've had to add rights for some system user to that folder.. "NET" something? I don't quite remember the name of the user but it was quite visible in the username that it was connected with .NET or Web)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜