Currently I'm developing an application with ASP.net 5 and it needs to get client certificates. The certificate used to be in Request.ClientCertificate and was available in a controller (v. 4.6), but now there is no such option in Request.
I'm not bonded to Core, because the application is only for Windows and IIS => I've set in project.json just .net 4.5.2 instead of dnx451 and dnxcore50 in the frameworks section, but the option hasn't appeared.
Is there any workaround or a particular library I should add to use client certificates in controllers with ASP.net 5 (RC1) or it is simply better to write the application on ASP.net 4.6?
Thank you in advance!
Related
I am developing on a Windows 11 machine and I have a .NET 6 Swagger WebApi solution that references .Net Framework 4.7.2 project (due to migration reasons it has to stay fw472).
I dockerized the api solution and deployed it into a Linux container locally on my machine. To my surprise I was able to browse the Swagger api and trigger a rest endpoint that uses the fw472 library which successfully returned the results.
My question is how does .Net 6 solution support using a .Net 472 class library when it is deployed into a Linux container?
I have a question and I searched it on the web and I can't find any answer.
How can I create a ASP.NET MVC web application sample in VS Code?
Note: I don't want to create a .NET Core application
And second question is: how can publish the ASP.NET MVC web application in VS Code?
Note: I using Kali Linux
No VS Code does not support ASP.NET Web Application. Refer https://code.visualstudio.com/docs/languages/csharp
Due to this focus, many standard C# project types are not recognized by VS Code. An example of a non-supported project type is an ASP.NET MVC Application (though ASP.NET Core is supported).
ASP.NET MVC Web Application will not run on any version of Linux as it has a hard dependency on the Windows OS (You could try Mono). .NET Core Web Applications can be run on Linux.
I want to create an ASP.NET Core MVC 2 web application which I could host on Linux and Windows (i.e. in both OS). So, I am to use .Net Core. But when I create new ASP.NET Core MVC 2 web application I see two comboboxes. At first I am to select either .NET Frmework or .NET Core. The second combobox contains only ASP.NET Core 2.0.
Q1:
Does it mean that ASP.NET Core 2.0 is technology which is implemented in both frameworks (.Net Framework and .NET Core)?
It is impossible to switch .Net Framework to .NET Core for such project later. I could use .NET Core but here Microsoft writes that I am to use .NET Framework if I want to use Windows Service...
I want to use Nginx for Windows on my computer (instead of IIS) - it is interesting for me to try it. :) Here Microsoft describes how to host ASP.NET Core web application on Linux with NGinx. At the article the Create the service file topic exists. But it is for Linux... So, if I want to host my ASP.NET Core MVC 2 web application on Nginx in Windows then I am forced to use Windows Services (look here). But in the Host an ASP.NET Core app in a Windows Service article Microsoft writes that I am to use .NET Framework instead of .NET Core...
Q2
Does it mean that I can't the same project use for build my web application for Linux and Windows (for Windows Service)? Does it mean that for my goal I am to create two project: for .NET Framework and for .NET Core and to share the code sources for both projects?
Q1
Does it mean that ASP.NET Core 2.0 is technology which is implemented
in both frameworks (.Net Framework and .NET Core)?
.NET Core 2.0 and .NET Framework 4.6.1 are both implementations of .NET Standard 2.0. What this means is that they can both do the same things, and work mostly the same, but .NET Framework contains some Windows only libraries (System libraries such as Windows Forms) that mean it can only run on Windows. .Net Core programs can run on Windows, Linux and MacOS.
It is impossible to switch .Net Framework to .NET Core for such
project later. I could use .NET Core but here Microsoft writes that I
am to use .NET Framework if I want to use Windows Service...
While this is technically possible, you really want to avoid it. It's a huge headache, and usually breaks a lot of your code, with missing dependancies etc.
I want to use Nginx for Windows on my computer (instead of IIS) - it
is interesting for me to try it. :) Here Microsoft describes how to
host ASP.NET Core web application on Linux with NGinx. At the article
the Create the service file topic exists. But it is for Linux... So,
if I want to host my ASP.NET Core MVC 2 web application on Nginx in
Windows then I am forced to use Windows Services (look here). But in
the Host an ASP.NET Core app in a Windows Service article Microsoft
writes that I am to use .NET Framework instead of .NET Core...
I haven't personally used NGinx for Windows, but it looks as though they want you to set the target version for your NET Core app to NET Framework for the purposes of their example. Since .NET Core doesn't have the references to System specific libraries, you can easily change target to NET Framework. This doesn't make it a NET Framework project, it just changes the runtime against which Visual Studio will build it.
Q2
Does it mean that I can't the same project use for build my web
application for Linux and Windows (for Windows Service)? Does it mean
that for my goal I am to create two project: for .NET Framework and
for .NET Core and to share the code sources for both projects?
You can absolutely use the same application for both platforms, however it'll be a little different to how you're used to it. Since .NET Core is platform agnostic, Visual Studio won't generate an exe for you, it'll just generate dll files. You then use the dotnet command at the command line to start the program, e.g.
dotnet helloWorld.dll
This is how you run the program on any OS, provided you have the .NET Core runtime installed (There are plenty of guides on how to do this online).
Hope I've answered everything clearly :)
On one side i have a Asp.Net Core WebApi 1.1 project hosted on a web server providing REST endpoints. On the other side i have a Windows Service project using .net framework 2.0.
.net 2.0 is a requirement and i can't update to a later version.
What is the best way to communicate between these two?
I never used .net2.0 so I'm not quite sure what my options are. Communicating with REST endpoints on the WebApi would be preferred, but i can't find a good way to achieve this as libraries like WCF/Json/.. are not available on 2.0.
Edit: The client (Windows Service) should be able to register itself to the web service (PUT), get a status and download a file from it (GET).
I am attempting to self host a Asp.Net 4.5 MVC 5 application. Now after some research it seems this cannot be done with this framework, it would require switching it out for Nancy.
I understand that Asp.Net 5 supports this with Owin. I have been able to convert my MVC project into the new Asp.Net 5 project (with the project.json) and set my runtime version as .net 4.5
"frameworks": {
"net45": {
"dependencies": { }
}
},
This is so I can still use the other .Net 4.5 projects in my solution (otherwise I need to upgrade all of my projects and their dependencies, which some do not support .Net 5 yet). Is there any way to self host like this?
Which Asp.Net 5 build are you targeting in your app? For the RC2 builds the hosting API has changed somewhat and therefore other examples you find online may not work anymore, please see here for more information on that, it also explains how other's are using IIS to self-host so hopefully that will prove useful to you:
Changes to hosting API
It would also be helpful to know which server you're planning on using to self-host your app. Generally Kestrel is used but this should always be behind a Web Server such as Nginx, Apache or IIS, and never exposed directly.