Skip to content
This repository has been archived by the owner on Dec 14, 2018. It is now read-only.

cshtml view returns 404 in vscode #6142

Closed
thienedits opened this issue Apr 15, 2017 · 13 comments
Closed

cshtml view returns 404 in vscode #6142

thienedits opened this issue Apr 15, 2017 · 13 comments

Comments

@thienedits
Copy link

I posted in the omnisharp repo but hopefully can get some more guidance here. I have a very simple controller returning a cshtml view. Works when project is opened in Visual Studio Code but not vscode.

dotnet/vscode-csharp#1252

@SilverioMiranda
Copy link

Upgrade your project to NetCore 1.1 with msbuild and try again

@pranavkm
Copy link
Contributor

What are you doing to run your application in vscode?

@thienedits
Copy link
Author

@pranavkm I am going to Debug window and clicking .Net Core Launch (web)

@pranavkm
Copy link
Contributor

What's the working directory set to in your application? The template assumes your content root is based off the current directory, so an incorrect directory would certainly explain the issue you're seeing here.

@thienedits
Copy link
Author

thienedits commented Apr 17, 2017

Hi @pranavkm another dev set this up and I am not very familiar with .Net but I think its currently a folder called DiceWeb6. Inside this directory there is a Controllers and Views directory

@thienedits
Copy link
Author

here is the vscode launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": ".NET Core Launch (web)",
            "type": "coreclr",
            "request": "launch",
            "preLaunchTask": "default",
            "program": "${workspaceRoot}\\bin\\Debug\\netcoreapp1.0\\DiceWeb6.dll",
            "args": [],
            "cwd": "${workspaceRoot}",
            "stopAtEntry": false,
            "internalConsoleOptions": "openOnSessionStart",
            "launchBrowser": {
                "enabled": true,
                "args": "${auto-detect-url}",
                "windows": {
                    "command": "cmd.exe",
                    "args": "/C start ${auto-detect-url}"
                },
                "osx": {
                    "command": "open"
                },
                "linux": {
                    "command": "xdg-open"
                }
            },
            "env": {
                "ASPNETCORE_URLS": "http://localhost:9876",
                "ASPNETCORE_ENVIRONMENT": "Development"  
            },
            "sourceFileMap": {
                "/Views": "${workspaceRoot}\\Views"
            }
        },
        {
            "name": ".NET Core Attach",
            "type": "coreclr",
            "request": "attach",
            "processId": "${command.pickProcess}"
        }
    ]
}

@pranavkm
Copy link
Contributor

The workspace settings seem right at first glance, but it would be useful to look at what the ContentRoot \ PWD is in a running application. Also, does it work if you execute dotnet run from the shell?

@thienedits
Copy link
Author

yes seems running dotnet run works.

@pranavkm
Copy link
Contributor

@thienedits, could you print out what the ContentRoot is from inside the process - running Console.WriteLine(Directory.GetCurrentDirectory()); from your Program.Main() should suffice?

@thienedits
Copy link
Author

@pranavkm

Hosting environment: Development
Content root path: C:\pub\inferno-core\src\DiceWeb6
Now listening on: http://*:9876
Application started. Press Ctrl+C to shut down.

@pranavkm
Copy link
Contributor

I tried setting up a using the preview2 CLI + the launchsetting.json you have (vscode auto generates something pretty identical) and it worked fine for me (this was on Ubuntu 16.04 machine, I don't have access to a OSX machine), and that seemed to work fine for me. At this point, I'd recommend updating to the RTM CLI tooling since dotnet run does work and I'm not sure if you're running in to a bug in the preview CLI tooling that was fixed.

@thienedits
Copy link
Author

ok i will take a look thanks.

@Eilon
Copy link
Member

Eilon commented May 13, 2017

Closing because there is not enough information to reproduce this problem.

@Eilon Eilon closed this as completed May 13, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants