Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to serve .aspx files via dotnet core (i.e. Kestrel)?

I have a bunch of simple .aspx files providing simple web pages for testing purposes. I'm running Linux and have no access to a Windows machine.

I could convert the .aspx pages into something else (NodeJS using Express, perhaps) but I risk altering the logic through mistakes as I make this conversion. This is my fallback position.

My current goal is to use dotnet core to build an environment into which I can drop each .aspx file (one at a time is fine) and see it running in a webserver as it was intended. I've constructed the base of such an environment via:

$ dotnet new -t web
$ dotnet restore
$ dotnet run

This gives me a working webserver running a default website on localhost:5000 - great! However I can't get it to execute, or even read, .aspx files; http://localhost:5000/favicon.ico does read the contents of wwwroot/favicon.ico, yet dumping foo.aspx into wwwroot/ and trying out http://localhost:5000/foo.aspx gives a 404 - I was expecting at least a 500 demanding that I configure serving of .aspx, or perhaps a 200 with the literal contents of foo.aspx, but 404? I added a wwwroot/test.txt file with new contents and it serves that just fine as static content.

Thinking I might be able to (ab)use the MVC setup I'd been provided by the default template I set up a new controller FooController, dumped foo.aspx into Views/Foo/Index.cshtml and got the thing executing finally, hacked the .cshtml file so it looked like the other provided .cshtml files (really just replacing <% %> with @{ }) and it still doesn't work because this .aspx file references Request.Form["data"] so I get an error: "The name 'Request' does not exist in the current context".

Am I barking up the wrong tree? I don't have any experience with ASPX or the new MVC infrastructure. My task is to translate code in Java to Python & Ruby that acts against these provided web pages. Can I easily serve the .aspx files on Kestrel or should I fall back to translating the ASPX stuff over to NodeJS?

Please note that suitability for a production environment is not relevant here; this is purely for dev testing and will not be served to the wider internet, or indeed anywhere except localhost.

like image 896
ahri Avatar asked Feb 17 '17 01:02

ahri


People also ask

Can we add ASPX page in .NET Core?

ASP.Net 5 is like ASP.Net MVC , you cannot add . aspx page but . cshtml razor view into your Views folder. Save this answer.

How do I run a ASPX file?

You can use Firefox, Chrome, Edge, or any browser. All you have to do is, right-click on the . aspx file, click on Open with, and select Chrome (your browser). If you can't find your desired browser, click on Choose another app and locate your specified browser from the Program file.

What is Kestrel in .NET Core?

Kestrel is a cross-platform web server for ASP.NET Core. Kestrel is the web server that's included and enabled by default in ASP.NET Core project templates. Kestrel supports the following scenarios: HTTPS. HTTP/2 (except on macOS†)


1 Answers

At this point, ASP.NET Web Forms are not supported in will not be supported with .NET Core.

You could easily get a VM with Windows and run it from there.

like image 152
Daniel A. White Avatar answered Nov 15 '22 23:11

Daniel A. White