0

I am pretty new to the C# and ASP.NET and now I am trying to understand what does the Endpoint in ASP.NET mean, or what is the essence of this concept, thank you!

Example:

app.UseMvc(route =>
            {
                route.MapRoute(name:"default", template:"{controller=Home}/{action=index}/{id?}");
            });

app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller=Home}/{action=Index}/{id?}");
            });

What are the differences when using this two method?

lynkewsw
  • 5
  • 3
  • As in "a tcp host and port"? Can you give a bit more context, or class name (used in whatever blog you read this) – Caius Jard Feb 22 '20 at 18:58
  • 1
    End-point is a URL, in MVC it could hit an action(method) within a controller. Add some example if you have. – as-if-i-code Feb 22 '20 at 18:59
  • Hi lynkewsw, a google of "asp.net endpoints" yielded, [Routing in ASP.NET Core | Microsoft Docs](https://learn.microsoft.com/en-us/aspnet/core/fundamentals/routing) does that help you? Perhaps look at some more of these results. – Love and peace - Joe Codeswell Feb 22 '20 at 19:04
  • In general an endpoint is a callable uri. – Wiktor Zychla Feb 22 '20 at 19:47
  • @CaiusJard Hey CaiusJard, thank you for your reply. So the context is I am taking a course teaching these but the instructor are using 2.2 while macOS can only install 3.0+ (please let me know if 2.2 can be installed on macOS), and when I follow his code, VS told me I need to disable endpoint, so maybe my question should be: What's the difference between UseMvc and UseEndpoints. Thank you! – lynkewsw Feb 22 '20 at 23:23
  • @as.if.i.code Hey as.if.i.code, thank you for your reply! Like my answer to Caius Jard, maybe my question should be: What's the difference between UseMvc and UseEndpoints. The example is added in the question, thank you! – lynkewsw Feb 22 '20 at 23:36
  • @Loveandpeace-JoeCodeswell Thank you!! That helps me to reform my question, really appreciate it! – lynkewsw Feb 22 '20 at 23:41
  • @WiktorZychla Hey WiktorZychla, thank you for your reply, I just reformed my question, please have a look, looking forward to your answer, thanks! – lynkewsw Feb 22 '20 at 23:44
  • I think you're setting yourself up for a fall if you keep on using a different operating system than your course tutor uses (your Mac can run Windows and Microsoft usually give students software for free?). I also didn't understand why you can't install netcore 2.2 on macos - https://dotnet.microsoft.com/download/dotnet-core/2.2 seems to have a macOS installer link, and even though 2.2 is end of life it will still work in an academic context, it's just not advisable to use it in a production context (security reasons ) – Caius Jard Feb 23 '20 at 07:31

1 Answers1

0

In your context an endpoint is a URL that causes a netcore server to do something (run some code) when a browser connects to the server, quotes the url as part of a http request and possibly includes a body or other parameter data

Per the comments, UseMvc/UseSignalR on 2.2 were effectively replaced by a single UseEndpoints in 3.0. The netcore migration guide discusses the differences in depth and makes recommendations on how to switch from UseMvc to UseEndpoints

Per my comment, I strongly recommend you shouldn't seek to establish a totally different dev environment to what your course teaches via/is expecting to see submissions of assignments in, just because you have a Mac and can't/won't make it the same environment the institution uses. Handing in an app that uses 3.0 to a tutor marking it on a machine that uses 2.2 may well get you fewer points because it doesn't compile

Caius Jard
  • 72,509
  • 5
  • 49
  • 80