开发者

ASP.NET - Page.Form.Action error

On my local development server, I am running version 2.0.50727.4955 on the live server I am running 2.0.50727.42.

On my live server I get:

Compiler Error Message: CS0117: 'System.Web.UI.HtmlControls.HtmlForm' does not contain a definition for 'Action'

On my development server everything works fine. Is this a .NET version issue or something else? Is there a way to make this work on my liver server with its current .Net version? Is there a way to upgrade from 2.0.50727.42 to 2.0.50727.4955?

Thanks

EDIT (Code):

    if (Request.PathInfo.Length != 0)
    {
        string reqPath = Request.PathInfo;
        string raw = Request.RawUrl;
        string url = Request.Url.ToString();
        if (reqPath.Length >开发者_如何学Go; 0)
            url = url.Replace(reqPath, "");
        if (raw.Length > 0)
            url = url.Replace(raw, "");

        litBasePath.Text = "<base href=\"" + url + "\">";
        Page.Form.Attributes["Action"] = raw;
    }

EDIT (Local Setup)

This is my local setup. I am not getting any compile errors when i run this locally.

ASP.NET - Page.Form.Action error

ASP.NET - Page.Form.Action error

ASP.NET - Page.Form.Action error


That server version indicates that it has never had patches applied.

.42 is the RTM release of .Net 2.0. (see wikipedia) .4955 was released in september of 2010 as a security update.

Before even bothering to figure out exactly what this issue is I would yell and scream at the people responsible for those servers (and their bosses) that every day they put off doing server patches they are putting your company at risk.

There have been a tremendous number of exploits released just in the last few months (POET was a big one), much less since 2.0 RTM'd, that would allow full access to the servers in question. And no, McAfee or any other "security" tool or firewall won't stop them.

Sorry to go on about this but there was a reason worms like Code Red and Nimda tore through tens of thousands of servers. That reason was simply that the people responsible for those servers failed to do their job and apply updates.


That said, your issue boils down to you are using 2.0 SP2 locally and your server doesn't have that applied. SP2 introduced the HtmlForm.Action attribute To get SP2 on your production server run windows update.


HtmlForm.Action does not exist in the unpatched 2.0 framework. Only in 2.0 sp2+. My guess is that your local environment you're building as a 3.5 app and using libraries that do not exist in your live environment.

In order set/change Action, I believe you need to use Page.Form.Attributes["action"] = "Some URL Here"

Or, if it's possible, patch your server (recommended) or install the .NET 3.5 Framework. in your live environment.


Version number clarification (this doesn't directly address your question, but is a bit too lengthy for a comment).

There are two .NET version numbers in play: one for the .NET framework (v2, v3.5, v4), and one for the ASP.NET ISAPI DLL (v2 or v4).

You have to set the .NET framework version used for compilation in Visual Studio in your project properties, and the ASP.NET DLL version used by IIS in the website or application pool configuration in the IIS manager (inetmgr.exe).

So, even though your websites are configured to use ASP.NET v2, the applications may (and probably will) use the .NET framework v3.5 or v4.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜