core icon indicating copy to clipboard operation
core copied to clipboard

hello world program in vs22

Open sirishaevani opened this issue 4 years ago • 4 comments

hello sir, I am using windows10 os.when i am doing hello world program in vs22 i am getting these errors..." C:\Users\siris\MyWebApp\Pages\Index.cshtml.cs(2,8): error CS1003: Syntax error, ',' expected C:\Users\siris\MyWebApp\Pages\Index.cshtml.cs(3,1): error CS1646: Keyword, identifier, or string expected after verbatim specifier: @ C:\Users\siris\MyWebApp\Pages\Index.cshtml.cs(4,13): error CS1002: ; expected C:\Users\siris\MyWebApp\Pages\Index.cshtml.cs(4,14): error CS1001: Identifier expected C:\Users\siris\MyWebApp\Pages\Index.cshtml.cs(4,14): error CS1001: Identifier expected C:\Users\siris\MyWebApp\Pages\Index.cshtml.cs(4,23): error CS1525: Invalid expression term '=' C:\Users\siris\MyWebApp\Pages\Index.cshtml.cs(5,1): error CS1022: Type or namespace definition, or end-of-file expected C:\Users\siris\MyWebApp\Pages\Index.cshtml.cs(5,2): error CS1525: Invalid expression term '<' C:\Users\siris\MyWebApp\Pages\Index.cshtml.cs(7,7): error CS1002: ; expected C:\Users\siris\MyWebApp\Pages\Index.cshtml.cs(7,12): error CS1001: Identifier expected C:\Users\siris\MyWebApp\Pages\Index.cshtml.cs(7,12): error CS1514: { expected C:\Users\siris\MyWebApp\Pages\Index.cshtml.cs(7,12): error CS1513: } expected C:\Users\siris\MyWebApp\Pages\Index.cshtml.cs(7,12): error CS8803: Top-level statements must precede namespace and type declarations. C:\Users\siris\MyWebApp\Pages\Index.cshtml.cs(7,12): error CS1525: Invalid expression term '=' C:\Users\siris\MyWebApp\Pages\Index.cshtml.cs(7,29): error CS1525: Invalid expression term '<' C:\Users\siris\MyWebApp\Pages\Index.cshtml.cs(8,17): error CS1002: ; expected C:\Users\siris\MyWebApp\Pages\Index.cshtml.cs(8,17): error CS1022: Type or namespace definition, or end-of-file expected C:\Users\siris\MyWebApp\Pages\Index.cshtml.cs(8,27): error CS1525: Invalid expression term '/' C:\Users\siris\MyWebApp\Pages\Index.cshtml.cs(8,33): error CS1525: Invalid expression term '<' C:\Users\siris\MyWebApp\Pages\Index.cshtml.cs(9,15): error CS1002: ; expected C:\Users\siris\MyWebApp\Pages\Index.cshtml.cs(9,23): error CS1003: Syntax error, ',' expected C:\Users\siris\MyWebApp\Pages\Index.cshtml.cs(10,7): error CS1002: ; expected C:\Users\siris\MyWebApp\Program.cs(1,1): error CS8802: Only one compilation unit can have top-level statements. Microsoft.NET.Sdk.Razor.SourceGenerators\Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator\Pages_Index_cshtml.g.cs(60,71): error CS0246: The type or namespace name 'IndexModel' could not be found (are you missing a using directive or an assembly reference?) Microsoft.NET.Sdk.Razor.SourceGenerators\Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator\Pages_Index_cshtml.g.cs(62,81): error CS0246: The type or namespace name 'IndexModel' could not be found (are you missing a using directive or an assembly reference?) Microsoft.NET.Sdk.Razor.SourceGenerators\Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator\Pages_Index_cshtml.g.cs(63,16): error CS0246: The type or namespace name 'IndexModel' could not be found (are you missing a using directive or an assembly reference?) C:\Users\siris\MyWebApp\Pages\Index.cshtml.cs(1,1): error CS0246: The type or namespace name 'page' could not be found (are you missing a using directive or an assembly reference?) C:\Users\siris\MyWebApp\Pages\Index.cshtml.cs(4,13): error CS7014: Attributes are not valid in this context. C:\Users\siris\MyWebApp\Pages\Index.cshtml.cs(7,3): error CS0103: The name 'div' does not exist in the current context C:\Users\siris\MyWebApp\Pages\Index.cshtml.cs(8,7): error CS0103: The name 'h1' does not exist in the current context C:\Users\siris\MyWebApp\Pages\Index.cshtml.cs(8,12): error CS0103: The name 'Hello' does not exist in the current context C:\Users\siris\MyWebApp\Pages\Index.cshtml.cs(8,19): error CS0103: The name 'world' does not exist in the current context C:\Users\siris\MyWebApp\Pages\Index.cshtml.cs(8,29): error CS0103: The name 'h1' does not exist in the current context C:\Users\siris\MyWebApp\Pages\Index.cshtml.cs(9,7): error CS0103: The name 'p' does not exist in the current context C:\Users\siris\MyWebApp\Pages\Index.cshtml.cs(9,11): error CS0103: The name 'The' does not exist in the current context C:\Users\siris\MyWebApp\Pages\Index.cshtml.cs(9,15): error CS0246: The type or namespace name 'time' could not be found (are you missing a using directive or an assembly reference?) Microsoft.NET.Sdk.Razor.SourceGenerators\Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator\Pages_Index_cshtml.g.cs(62,171): error CS0246: The type or namespace name 'IndexModel' could not be found (are you missing a using directive or an assembly reference?)

https://dotnet.microsoft.com/en-us/learn/aspnet/hello-world-tutorial/modify i am doing it from here pls clarify my doubt

sirishaevani avatar Oct 06 '22 09:10 sirishaevani

Can you provide your source code? It's hard to give you any advice only based on the compile-time errors list.

hwfbcisod avatar Oct 06 '22 12:10 hwfbcisod

You probably modified the Index.cshtml.cs file and not the Index.cshtml one. Maybe start over making sure you edit the right one?

Otherwise, paste the following code in your Index.cshtml.cs file to restore to its original state and make the changes to the right file

using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;

namespace MyWebApp.Pages;

public class IndexModel : PageModel
{
    private readonly ILogger<IndexModel> _logger;

    public IndexModel(ILogger<IndexModel> logger)
    {
        _logger = logger;
    }

    public void OnGet()
    {

    }
}

mairaw avatar Oct 19 '22 15:10 mairaw

This issue is stale because there has been no response to a request for more information for 7 days.

github-actions[bot] avatar Oct 26 '22 16:10 github-actions[bot]

This issue was closed because there was no response to a request for more information for 10 days.

github-actions[bot] avatar Oct 29 '22 17:10 github-actions[bot]