Navigating to a different page within the ASP.Net MVC application results in a syntax error within the automatically generated code

Snippet from my _layout.cshtml file

<body>
<!--
NAVBAR
-->
<div class="navBar">
    <input id="homeButton" type="submit" name="homeButton" value="Home"/>
    <input id="toolsButton" type="submit" name="toolsButton" value="Tools"/>
    <input id="contactButton" type="submit" name="contactButton" value="Contact Me"/>
    <input id="supportButton" type="submit" name="supportButton" value="Support"/>
    <input id="aboutButton" type="submit" name="aboutButton" value="About"/>
</div><!--TODO: STYLE THESE -->

<script>
const homeButton = document.getElementById("homeButton");
const toolsButton = document.getElementById("toolsButton");
const contactButton = document.getElementById("contactButton");
const supportButton = document.getElementById("supportButton");
const aboutButton = document.getElementById("aboutButton");

homeButton.addEventListener("click", () => {
    window.location.href = "/";
});

toolsButton.addEventListener("click", () => {
    window.location.href = "/Tools/Index"; // "/Tools" doesn't work either
});

contactButton.addEventListener("click", () => {
    window.location.href = "/";
});

supportButton.addEventListener("click", () => {
    window.location.href = "/";
});

aboutButton.addEventListener("click", () => {
    window.location.href = "/";
});
</script>

The error generated when button clicked

Server Error in '/' Application.
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS1003: Syntax error, '>' expected

Source Error:


Line 29:     
Line 30:     
Line 31:     public class _Page_Views_Tools_Index_cshtml : System.Web.Mvc.WebViewPage<LgbtqWebsiteNoDb.Models.Tool;> {
Line 32:         
Line 33: #line hidden


Source File: c:\Users\marfx\AppData\Local\Temp\Temporary ASP.NET Files\root\ec7221e8\6a6fd7fe\App_Web_index.cshtml.f024d85f.citsmrxd.0.cs    Line: 31 

Detailed compiler output

C:\Program Files (x86)\IIS Express> "C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe" /t:library /utf8output /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_32\System.Web\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Web.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Data.DataSetExtensions\v4.0_4.0.0.0__b77a5c561934e089\System.Data.DataSetExtensions.dll" /R:"C:\WINDOWS\Microsoft.Net\assembly\GAC_32\System.Data\v4.0_4.0.0.0__b77a5c561934e089\System.Data.dll" /R:"C:\Users\marfx\AppData\Local\Temp\Temporary ASP.NET Files\root\ec7221e8\6a6fd7fe\assembly...
* Compiler output goes on here *

I have tried to redirect the users to other pages via Razor with

Response.Redirect("/Tools");
but this doesn't work either, throwing a different exception on the same line (compiler just picked a different character to throw on).

My Tools controller

using System.Collections.Generic;
using System.Web.Mvc;
using LgbtqWebsiteNoDb.Models;
using static LgbtqWebsiteNoDb.Models.Tool;
using Microsoft.Ajax.Utilities;

namespace LgbtqWebsiteNoDb.Controllers
{
    public class ToolsController : Controller
    {
        private static readonly List<Tool> Tools = new List<Tool>()
...
* More code follows *

Tools model

public class Tool
    {
        /// <summary>
        /// Getter and Setter for the name of a given tool
...
* More code follows *

Tools/Index.cshtml

@model LgbtqWebsiteNoDb.Models.Tool;
<!DOCTYPE html>
...
* More HTML code follows *

I am using .Net v4.7.2 (I would be using 5.0.0 but none of my IDEs seem to want to use the newest version, I'm on a time crunch so can't spend ages debugging that so I'm just making do)

Cheers

Answer №1

I'm a bit uncertain, however, the presence of the ; at the end of the line:

@model LgbtqWebsiteNoDb.Models.Tool;

within the file Tools/Index.cshtml could potentially be causing issues.

Answer №2

I have found a syntax error in your code – it looks like you missed the closing angle bracket '>' for the img tag in the file Tools/Index.cshtml.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

A tutorial on making a POST request using axios in a React application

I am struggling with my JavaScript skills I need assistance with calling the following CURL command successfully: curl -X POST -H "Content-Type: application/json" -u john.doe:moqui -d "{\"firstName\":\"Hung&bso ...

Deactivate multiple input fields by utilizing various radio buttons

I need help with enabling and disabling input fields based on radio button selection. When the first radio button is selected, I want to disable three input fields, when the second is selected, only two specific input fields should be enabled (SHIFT START ...

Creating an if statement that validates whether all variables have non-null values

I am still getting the hang of javascript and working on some coding projects from my textbooks. The current task involves creating an if statement to check if the values of the elements referenced by the names fname, lname, and zip are all not null. Here ...

What are the steps for running a separate version of the selected_process and outdated_process?

Here's the code I've written to combine two history components into one. I'm using an if-else loop to achieve this, and it seems to be working fine. However, both icons end up showing all outdated processes. useEffect(() => { getVers ...

Issue when attempting to animate an SVG point using translateX transformation

I am attempting to create a basic animation using the translate X property on a section of my svg when hovering over the element. Here is the code I have so far: <html> <style> .big-dot:hover { transform: translateX(20px); animat ...

Using JavaScript to create a JSON object within a table

Currently, I am facing a challenge in creating a JSON object from an HTML table using JavaScript. While I can successfully retrieve the values of each cell in JavaScript, the issue lies in organizing and retrieving them as per my requirements. Here is the ...

Using jQuery, you can easily modify the color of a TD cell by applying the css properties assigned to the div element

I am attempting to implement a jQuery script that will execute upon the loading of the document. The objective is for the script to retrieve the background color of a div located within a td cell and apply it as the background color for the respective td c ...

Retrieve precise information from JSON for use in React applications

Here is a sample JSON file : [{ "name": "bagette", "price": "0.200" }, { "name": "farine", "price": "1" }, { "name": "tomato", "price": "1.200" }, { "name": "chocola", "price": "4.000" }] I need assistance with extracting data from this J ...

What is the most efficient way to check for the presence and truthiness of a nested boolean in Node.js?

There are instances where I must verify the deeply nested boolean value of an object to determine its existence and whether it is set to true or false. For instance, I need to ascertain if payload.options.save is assigned a value of false, yet I am uncert ...

Is there any justification for not utilizing nested EF entity contexts?

using (var connection = new DatabaseConnection()) { using (var transaction = new DatabaseTransaction()) { } } Although this code functions as intended, it leaves a lingering sense of unease... Is there any specific reason to avoid nesting using s ...

Creating a server that is exclusive to the application in Node.js/npm or altering the response body of outgoing requests

As I work on developing a node app, the need for a server that can be used internally by the app has become apparent. In my attempts to create a server without listening to a port, I have hit a roadblock where further actions seem impossible: let http = ...

What is the best way to adjust a div's height to fill the remaining space of the viewport after the header's height

Is there a way to create a hero section that fills 100vh minus the height of the header, especially when the height of the header is not fixed? I initially used CSS with a height property set to calc(100vh - 310px), where 310px represents the height of t ...

How can I access properties of generic types in TypeScript?

Converting the generic type to any is a valid approach (The type E could be a typescript type, class, or interface) of various entities like Product, Post, Todo, Customer, etc.: function test<E>(o:E):string { return (o as any)['property' ...

Adding and removing classes in NativeScript: A step-by-step guide

Attempting to lower the opacity of my StackLayout while making an Ajax API call. The structure of my page is as follows: <Page loaded="pageLoaded" class="page" xmlns="http://www.nativescript.org/tns.xsd"> <ActionBar title="Settings" clas ...

Is there a way to prevent redundancy when exporting functions in Node.js?

Is there a way to avoid repeating module.exports or usuariosControllers when writing a small API in express for fun? module.exports.getUsuarios = (request, response) => {}; module.exports.crearUsuario = (request, response) => {}; module.exports. ...

Could anyone assist me in positioning my personalized Context Menu beside my cursor?

If possible, I would appreciate some assistance with my custom context menu. It may require some minor tweaks or a fresh idea on how to address the issue. Ideally, I would like to keep the HTML and CSS somewhat unchanged. [I'm not sure what to write ...

Null values in ExtJS JSON records are handled seamlessly

How can I make a grid recognize when a JSON property changes from null to a value and mark it as isDirty? { "prop1": null, "prop2": "", "prop3": "my val" } When a user edits the prop1 cell in an Ext.grid.EditorGridPanel for the first time, it is no ...

Applying CSS rules from an array to elements by looping through

I'm looking for a way to allow users to input CSS styles and have those styles applied to the last selected element, which is determined by the "rangeselector" variable. Currently, the code selects the correct element, but only the first CSS rule is b ...

Three.js: Transparent background for background elements and png particles

I'm struggling with making the background invisible and setting the alpha channel on my particles. I was hoping to use your example script wegl_particles_sprite for the Christmas season. I adjusted it to fit my needs by placing it in a fullscreen div ...

Fill in the missing keys, values, and data within the JSON object

My JSON data consists of various objects with unique dates and site names. The dataset contains distinct dates such as: 2019-10-01, 2019-10-02, 2019-10-03, 2019-10-04, 2019-10-05. Some dates might be missing for certain sites in the dataset. For example, o ...