Does VS Code support server-side code in ASPX files?

10,853

Solution 1

VSCode is built to support .NET Core apps. .NET Core does not support ASP.NET Web Forms (and they probably never will). As noted correctly it is evaluated as HTML instead now.

That said, I don't think the issue in particular is VSCode, but more the compiler that isn't implemented to support Web Forms. I guess they just left out support for the ASPX syntax out of VSCode for that reason.

Solution 2

There is now an extension in the Marketplace called HTML (C#) which is a port from a Sublime plugin. I found it by searching for aspx in the Extensions sidebar. Picture of Marketplace Extension Search

Here's the link to the Github repo if that suits you better: https://github.com/fireside21/vscode-cshtml

Once that was loaded up I had no more errors from the incorrect assumption that I was editing a .js file.

Solution 3

Found this aspx-html extension that helped me a bit. Made those oooold aspx vbscript files readable at least. Google translate required though :)

"Provides syntax highlighting, parenthesis matching, and snippet functionality in the ASPX file."

https://marketplace.visualstudio.com/items?itemName=QQZZFT.aspx-html

Share:
10,853

Related videos on Youtube

Peter
Author by

Peter

Updated on June 04, 2022

Comments

  • Peter
    Peter almost 2 years

    When I open an ASPX (ASP.NET Web Forms) file with embedded server-side code in Visual Studio Code, I am getting a lot of error highlights.

    Here is a very minimal example: ASPX in VSCode

    Is there an extension I should have installed (I did install the C# extension) or is this an unsupported scenario? Or am I just really messing up here?

    • Arnaud Weil
      Arnaud Weil almost 7 years
      Using Visual Studio Code to edit ASP.NET Web Forms sounds like using the internet in order to handwrite a post-it note. If you're running on a Windows box, I'd strongly recommend using the full-blown Visual Studio.
    • Richard
      Richard almost 7 years
      Given WebForms is not the way forward for ASP.NET I doubt if there is any inbuilt support (particularly for inline code – given the error VSCode seems to be assuming you're writing JS) so anything would come from a third party extension. Have you tried searching?
    • Peter
      Peter almost 7 years
      @ArnaudWeil Weird comparison, but I do write all my post-its online (my own MediaWiki install). I'll be using Sublime for aspx editing (they're not being compiled, so VS is overkill).
  • Peter
    Peter almost 7 years
    Sounds logical, thanks! Too bad having to switch editors to edit legacy code, but you can't have it all.
  • DavidG
    DavidG almost 7 years
    Not my DV but a couple of points. VS Code is just a text editor so it should be fairly simple to "support" any language. The problem is that it currently treats .aspx files as HTML. But yeah, who wants to support such legacy stuff, and anyway, embedded code in an aspx file is really bad practice.
  • Patrick Hofman
    Patrick Hofman almost 7 years
    In order to have syntax highlighting and intellisense you still need to compile the thing @davidg
  • DavidG
    DavidG almost 7 years
    For intellisense perhaps, but not for syntax highlighting. But that depends on what you mean by "support" now.
  • Patrick Hofman
    Patrick Hofman almost 7 years
    Okay, you have to parse it then.
  • Adam Plocher
    Adam Plocher about 6 years
    I found this post for the same reason. I maintain an old site (NOT written by me, just FYI) that has thousands of lines of VB written directly into ASPX files. It's nasty and the client doesn't seem to care about this site so whatever small edits they have me do to make it hobble along are done on the live files on the server (I know, I know, horrible). I would just like some decent syntax highlighting in a light weight(ish) text editor. Surprised no extensions exist for this language support...
  • Tony Wall
    Tony Wall over 5 years
    Yes @PatrickHofman is right, MS can't generate the code necessary to work with ASPX because then they'd have to port the whole legacy stuff to run on Mac and Linux (we must remember it's primarily a cross-platform tool). An extension only running on Windows could work I guess. Or remote debugging support of a deployed VM running Windows, if they found a workaround for generating the IntelliSense remotely. So not likely then. This is like new world vs old world so I get that and without such limits you know too many people would not switch-up and we'd be stuck in the dark ages ;-)