配置Visual Studio 2008以编辑旧版JScript ASP文件

时间:2021-08-08 05:02:53

I'm working on a project that combines .NET with some legacy ASP code via COM interop. The legacy ASP is written in JScript - files look like this helloworld.asp example.

我正在开发一个项目,通过COM互操作将.NET与一些遗留的ASP代码结合起来。传统ASP是用JScript编写的 - 文件看起来像这个helloworld.asp示例。

<%@Language="JScript"%>
<html>
<head>
  <title>Jscript ASP Page</title>
</head>
<body>
  <h1>JScript ASP</h1>
  <p>This is JScript ASP at <%=new Date()%></p>
  <%
  var helloWorld = Server.CreateObject("Interop.HelloWorld")
  helloWorld.Name = "Dylan"
  %>
  <%=helloWorld.SayHello() %>
  </body>
</html>

I'd really like to use VS2008 to edit the legacy ASP code along with the rest of the project, but the Intellisense is behaving extremely strangely. One minute it'll be giving me the correct JScript keywords and methods:

我真的很想使用VS2008来编辑遗留的ASP代码以及项目的其余部分,但是Intellisense的表现非常奇怪。一分钟它会给我正确的JScript关键字和方法:

JS Intellisense in VS2008 - working http://www.dylanbeattie.net/vs_js_working.jpg

VS2008中的JS Intellisense - 工作http://www.dylanbeattie.net/vs_js_working.jpg

...so I'll type a line, press Enter, start typing the next line, and the exact same keystrokes will give me what appears to be VBScript intellisense instead:

...所以我将键入一行,按Enter键,开始键入下一行,完全相同的键击将给我看起来像VBScript intellisense:

ASP intellisense in VS2008 - broken http://www.dylanbeattie.net/vs_js_wrong.jpg

VS2008中的ASP intellisense - 破坏了http://www.dylanbeattie.net/vs_js_wrong.jpg

Is there any way I can tell VS that .asp files are ALWAYS Javascript code, and never to use VB code at all? Having the IDE turn "var" into "vArray" when you press Enter is proving a little frustrating...

有什么方法我可以告诉VS .asp文件总是Javascript代码,永远不会使用VB代码?当您按Enter键时,IDE将“var”变为“vArray”,这有点令人沮丧......

Help me, *. You're my only hope.

帮帮我,*。你是我唯一的希望。

1 个解决方案

#1


4  

Classic ASP intellisense is, as you've observed, broken in VS2008. Microsoft actually completely cut support for Classic ASP syntax coloring and intellisense in VS2008 RTM, then restored it in SP1 due to outcry from customers. Take a look at this bug report on the Microsoft Connect site for more info on how it got restored.

正如您所观察到的,经典ASP智能感知在VS2008中被打破了。微软实际上完全削减了对VS2008 RTM中经典ASP语法着色和智能感知的支持,然后由于客户的强烈*而在SP1中恢复了它。请查看Microsoft Connect站点上的此错误报告,以获取有关如何还原的更多信息。

Anyway, let me detail exactly how it's broken. What you're seeing is not actually VB intellisense-- instead, you're seeing methods and objects which are present in any of the following:

无论如何,让我详细说明它是如何破碎的。你所看到的实际上并不是VB intellisense--相反,你会看到以下任何一种方法和对象:

  • the server-side Response object sometimes other server-side objects like Session or Request, as if there were a javascript "with" statement for these objects before any of your code. this makes no sense-- it's a bug in VS.
  • 服务器端的Response对象有时是其他服务器端对象,如Session或Request,就好像在你的任何代码之前有这些对象的javascript“with”语句一样。这毫无意义 - 这是VS中的一个错误。

  • the client-side window object (!!!!). This makes no sense since this is server-side script. it's a bug in VS.
  • 客户端窗口对象(!!!!)。这是没有意义的,因为这是服务器端脚本。这是VS中的一个错误。

  • javascript keywords and global objects like String. This is expected (although if you define your script using runat=server, it works more reliably-- if I define the script with <% %> I often don't get proper keyword intellisense.
  • javascript关键字和全局对象,如String。这是预期的(尽管如果使用runat = server定义脚本,它的工作更可靠 - 如果我使用<%%>定义脚本,我通常无法获得正确的关键字智能感知。

Note that none of these are VB Intellisense-- what you're seeing are simply PascalCased methods of valid built-in methods of the Request, Response, etc. objects built into Classic ASP's server-side script object model.

请注意,这些都不是VB Intellisense--您所看到的只是PascalCased方法,它是Classic ASP服务器端脚本对象模型中内置的Request,Response等对象的有效内置方法。

Anecdotally, I've found intellisense to work much more naturally in runat=server script blocks than <% %> blocks. At least with runat=server, I get intellisense for typing "Request.", "Response.", etc. and also jscript keyword intellisense seems to work better in those blocks too.

有趣的是,我发现intellisense在runat = server脚本块中比<%%>块更自然地工作。至少对于runat = server,我得到intellisense用于输入“Request。”,“Response。”等等。而jscript关键字intellisense似乎也在这些块中运行得更好。

There are other quirks in intellisense, like when you have a <% %> script block, when you type a character, the character is ignored in the list of intellisense choices you get back. (this also works better in runat=server blocks)

intellisense中还有其他的怪癖,比如当你有一个<%%>脚本块时,当你输入一个字符时,你会得到的intellisense选择列表中的字符会被忽略。 (这在runat = server blocks中效果更好)

In other words, this is all very broken. I have no inside information about why it's so busted, other than this is a feature which was deprecated in VS2008, brought back in a service pack, and likely has far less testing than other parts of VS-- so it's not surprising it's broken. Especially when you consider that it's supporting a feature, classic ASP, which Microsoft probably wants to go away. That doesn't mean the Redmontonians are actively trying to sabotage this, but in a team with limited resources, making classic ASP work great is probably not going to attract the same level of attention as, for example, ASP.NET MVC.

换句话说,这一切都非常破碎。我没有关于它为什么如此被破坏的内部信息,除了这是一个在VS2008中被弃用的功能,带回到服务包中,并且可能远远少于VS的其他部分的测试 - 因此它不会令人惊讶。特别是当你认为它支持一个功能,经典的ASP,微软可能想要消失。这并不意味着Redmontonians正在积极地试图破坏这一点,但是在一个资源有限的团队中,使经典的ASP工作变得很好可能不会像ASP.NET MVC那样吸引相同程度的关注。

That said, IMHO even this limited support is better than what was there in VS2008 RTM, when classic ASP files looked like notepad, wtih no intellisense or syntax coloring at all.

也就是说,恕我直言,即使这种有限的支持也比VS2008 RTM更好,当时经典的ASP文件看起来像记事本,根本没有智能感知或语法着色。

If you're annoyed at this sorry state of affairs, I'd suggest filing a bug report at https://connect.microsoft.com/VisualStudio. Just like a bug report got Microsoft to restore classic ASP intellisense in VS2008 SP1, it might get them to fix it for SP2 and/or VS2010. You might also want to check out the latest VS2010 beta to see if the problem is fixed or worse.

如果您对这种令人遗憾的事态感到恼火,我建议您在https://connect.microsoft.com/VisualStudio上提交错误报告。就像一个错误报告让微软在VS2008 SP1中恢复经典ASP智能感知,它可能会让他们为SP2和/或VS2010修复它。您可能还想查看最新的VS2010测试版,看看问题是否已修复或更糟。

Sorry if this isn't the answer you were hoping for. :-(

对不起,如果这不是您希望的答案。 :-(

#1


4  

Classic ASP intellisense is, as you've observed, broken in VS2008. Microsoft actually completely cut support for Classic ASP syntax coloring and intellisense in VS2008 RTM, then restored it in SP1 due to outcry from customers. Take a look at this bug report on the Microsoft Connect site for more info on how it got restored.

正如您所观察到的,经典ASP智能感知在VS2008中被打破了。微软实际上完全削减了对VS2008 RTM中经典ASP语法着色和智能感知的支持,然后由于客户的强烈*而在SP1中恢复了它。请查看Microsoft Connect站点上的此错误报告,以获取有关如何还原的更多信息。

Anyway, let me detail exactly how it's broken. What you're seeing is not actually VB intellisense-- instead, you're seeing methods and objects which are present in any of the following:

无论如何,让我详细说明它是如何破碎的。你所看到的实际上并不是VB intellisense--相反,你会看到以下任何一种方法和对象:

  • the server-side Response object sometimes other server-side objects like Session or Request, as if there were a javascript "with" statement for these objects before any of your code. this makes no sense-- it's a bug in VS.
  • 服务器端的Response对象有时是其他服务器端对象,如Session或Request,就好像在你的任何代码之前有这些对象的javascript“with”语句一样。这毫无意义 - 这是VS中的一个错误。

  • the client-side window object (!!!!). This makes no sense since this is server-side script. it's a bug in VS.
  • 客户端窗口对象(!!!!)。这是没有意义的,因为这是服务器端脚本。这是VS中的一个错误。

  • javascript keywords and global objects like String. This is expected (although if you define your script using runat=server, it works more reliably-- if I define the script with <% %> I often don't get proper keyword intellisense.
  • javascript关键字和全局对象,如String。这是预期的(尽管如果使用runat = server定义脚本,它的工作更可靠 - 如果我使用<%%>定义脚本,我通常无法获得正确的关键字智能感知。

Note that none of these are VB Intellisense-- what you're seeing are simply PascalCased methods of valid built-in methods of the Request, Response, etc. objects built into Classic ASP's server-side script object model.

请注意,这些都不是VB Intellisense--您所看到的只是PascalCased方法,它是Classic ASP服务器端脚本对象模型中内置的Request,Response等对象的有效内置方法。

Anecdotally, I've found intellisense to work much more naturally in runat=server script blocks than <% %> blocks. At least with runat=server, I get intellisense for typing "Request.", "Response.", etc. and also jscript keyword intellisense seems to work better in those blocks too.

有趣的是,我发现intellisense在runat = server脚本块中比<%%>块更自然地工作。至少对于runat = server,我得到intellisense用于输入“Request。”,“Response。”等等。而jscript关键字intellisense似乎也在这些块中运行得更好。

There are other quirks in intellisense, like when you have a <% %> script block, when you type a character, the character is ignored in the list of intellisense choices you get back. (this also works better in runat=server blocks)

intellisense中还有其他的怪癖,比如当你有一个<%%>脚本块时,当你输入一个字符时,你会得到的intellisense选择列表中的字符会被忽略。 (这在runat = server blocks中效果更好)

In other words, this is all very broken. I have no inside information about why it's so busted, other than this is a feature which was deprecated in VS2008, brought back in a service pack, and likely has far less testing than other parts of VS-- so it's not surprising it's broken. Especially when you consider that it's supporting a feature, classic ASP, which Microsoft probably wants to go away. That doesn't mean the Redmontonians are actively trying to sabotage this, but in a team with limited resources, making classic ASP work great is probably not going to attract the same level of attention as, for example, ASP.NET MVC.

换句话说,这一切都非常破碎。我没有关于它为什么如此被破坏的内部信息,除了这是一个在VS2008中被弃用的功能,带回到服务包中,并且可能远远少于VS的其他部分的测试 - 因此它不会令人惊讶。特别是当你认为它支持一个功能,经典的ASP,微软可能想要消失。这并不意味着Redmontonians正在积极地试图破坏这一点,但是在一个资源有限的团队中,使经典的ASP工作变得很好可能不会像ASP.NET MVC那样吸引相同程度的关注。

That said, IMHO even this limited support is better than what was there in VS2008 RTM, when classic ASP files looked like notepad, wtih no intellisense or syntax coloring at all.

也就是说,恕我直言,即使这种有限的支持也比VS2008 RTM更好,当时经典的ASP文件看起来像记事本,根本没有智能感知或语法着色。

If you're annoyed at this sorry state of affairs, I'd suggest filing a bug report at https://connect.microsoft.com/VisualStudio. Just like a bug report got Microsoft to restore classic ASP intellisense in VS2008 SP1, it might get them to fix it for SP2 and/or VS2010. You might also want to check out the latest VS2010 beta to see if the problem is fixed or worse.

如果您对这种令人遗憾的事态感到恼火,我建议您在https://connect.microsoft.com/VisualStudio上提交错误报告。就像一个错误报告让微软在VS2008 SP1中恢复经典ASP智能感知,它可能会让他们为SP2和/或VS2010修复它。您可能还想查看最新的VS2010测试版,看看问题是否已修复或更糟。

Sorry if this isn't the answer you were hoping for. :-(

对不起,如果这不是您希望的答案。 :-(