Error handling nav menu in visual studio 2015 web forms with c #

0

I am developing a website, I have put it in a menu using nav with a couple of submenus, when I run the program it enters the first menu option correctly, but when I access a second option it gives me the following error:

Server error in the application '/'.

The resource is not found. in the href I give the following url "Maintenance / pagina.aspx", when it gives the error it adds another "Maintenance" leaves it in the following way "Maintenance / Maintenance / pagina.aspx", Maintenance is a folder within the project where several pages are hosted.

This is the code I use:

<ul class="nav">
  <li><a href="Default.aspx">Inicio</a></li>
  <li><a href="Acercade.aspx">Acerca de</a></li>
  <li><a href="Contacto.aspx">Contacto</a></li>
  <li><a>Movimientos</a>
    <ul>
        <li><a href="Movimientos/Pagina1.aspx">Proceso1</a></li>
        <li><a href="Movimientos/Pagina2.aspx">Proceso2</a></li>
        <li><a href="Movimientos/Pagina3.aspx">Proceso3</a></li>
    </ul>
  </li>
  <li><a href="#">Mantenimientos</a>
    <ul>
        <li><a href="Mantenimientos/Proceso4.aspx">Proceso4</a></li>
        <li><a href="Mantenimientos/Proceso5.aspx">Proceso5</a></li>
    </ul>
  </li>
</ul>
    
asked by Rodolfo Ruiz 08.07.2018 в 18:34
source

1 answer

0

If you look at the links in Maintenance you do not have a Page but a Process, surely that is the error. Your code should look like this:

The changes are in the last two links, you have them as process4.aspx and process5.aspx and I have set them as page4.aspx and page5.aspx.

<ul class="nav">
  <li><a href="Default.aspx">Inicio</a></li>
  <li><a href="Acercade.aspx">Acerca de</a></li>
  <li><a href="Contacto.aspx">Contacto</a></li>
  <li><a>Movimientos</a>
    <ul>
        <li><a href="Movimientos/Pagina1.aspx">Proceso1</a></li>
        <li><a href="Movimientos/Pagina2.aspx">Proceso2</a></li>
        <li><a href="Movimientos/Pagina3.aspx">Proceso3</a></li>
    </ul>
  </li>
  <li><a href="#">Mantenimientos</a>
    <ul>
        LOS CAMBIOS SON ESTOS DOS ENLACES:
        <li><a href="Mantenimientos/Pagina4.aspx">Proceso4</a></li>
        <li><a href="Mantenimientos/Pagina5.aspx">Proceso5</a></li>
    </ul>
  </li>
</ul>

To solve your problem and without seeing the rest of the code I can think of two ways to solve it, if the menu you copy and paste it on each page you can edit the routes depending on the page you are on, for example if you are in Movements / Pagina1.aspx the path to access About should be ../Acercade.aspx, that is, you have to leave the Movements folder and then access the file, or to access Pagina2.aspx the path has to be Pagina2.aspx, without adding Movements because you are already in that folder.

But if the menu does not copy and paste it but you have it in a separate file and you call it on each page, what you can do is have all the files in the same folder, for example you delete the Movements and Maintenance folders After removing your files, in this way you will have all the files in the same level and you will not have to edit the route depending on where you are, simply by putting the name of the file you can access it. If you choose the second option, your code should look like this:

<ul class="nav">
  <li><a href="Default.aspx">Inicio</a></li>
  <li><a href="Acercade.aspx">Acerca de</a></li>
  <li><a href="Contacto.aspx">Contacto</a></li>
  <li><a>Movimientos</a>
    <ul>
        <li><a href="Pagina1.aspx">Proceso1</a></li>
        <li><a href="Pagina2.aspx">Proceso2</a></li>
        <li><a href="Pagina3.aspx">Proceso3</a></li>
    </ul>
  </li>
  <li><a href="#">Mantenimientos</a>
    <ul>
        <li><a href="Pagina4.aspx">Proceso4</a></li>
        <li><a href="Pagina5.aspx">Proceso5</a></li>
    </ul>
  </li>
</ul>
    
answered by 09.07.2018 / 15:39
source