How to choose the page URL (vice versa)

Asked

Viewed 62 times

0

Hello, I’m developing a project with .NET Core Razor, and I have a file structure like this:

inserir a descrição da imagem aqui

When in the browser I go to the Menuprincipal page, the URL looks like this:

https://localhost:44390/Menu/Menuprincipal

I would like, to be more organized, my URL to appear as follows:

https://localhost:44390/Menu

If anyone knows if there’s any way to do that, could you give me a hand? Thanks.

Ah, one more thing related... I have the link of a url of a page that I will still create. The Link is this: (I’m not the one who defines this link, I just get it from another file)

https://localhost:44390/Menu/Binaries/Searches/searchersSp1Psearch

This URL for me is cool, but is there any way I can create this file, with this url, without having to create a structure like the one that is indicating the URL? Or I need to create all the same structure is in the URL?

  • Using (or intending to use) MVC?

  • @Ronaldoaraújoalves. I am not using or intend to use.

  • Change the file name in the Menuprincipal Menu folder to Index

  • it wouldn’t look good, I’ll need to do it not only with this file, but with others as well. I won’t create a folder for each and put all files with Index name. @Alissonmarqui

3 answers

1

You can annotate your method in Controller with the annotation [Route("/")]

Example:

[Route("menu")]
public class DistrictController : ControllerBase
{

    [Route("/")] 
    public IActionResult Index(int id)
    {
    }
}
  • Alisson, it’s a project .Net Core Razor, nay mvc... i do not use Controller

0

  • He directed me to what I need, but I haven’t solved it yet. But thank you for your help

0

This is the path that has been taken to the archive of your web page. As if it were a directory.

To stay the way you want, you have to take the file inside the menu folder and rename it to "Menu".

  • Place the "Menu" file in the root folder

  • Yes, I know this is the way, but I would like to know if there is any way to leave it where it is (inside the Menu folder) and even then, the url path appears in another way.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.