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

Bug in Razor Page Model #7554

Closed
Eilon opened this issue Mar 27, 2018 · 4 comments
Closed

Bug in Razor Page Model #7554

Eilon opened this issue Mar 27, 2018 · 4 comments

Comments

@Eilon
Copy link
Contributor

Eilon commented Mar 27, 2018

From @rishabhack on March 26, 2018 21:22

public  JsonResult GetResult(){
    return Json();
}

Will give error the name 'Json' does not exist in current context in razor page modal while working fine when page is drives from controller
I can't use razor page model due to this serious issue and need to move to MVC approach instead of page modal. Please Resolve this Bug.

Copied from original issue: dotnet/aspnetcore#3003

@pranavkm pranavkm changed the title Bug in Razor Page Modal Bug in Razor Page Model Mar 27, 2018
@Eilon
Copy link
Contributor Author

Eilon commented Mar 27, 2018

I believe this is by-design because the Json helper is meant for APIs, not pages.

There are some historical notes in #5846 under the "Methods Pages Don't Need" section.

@pranavkm
Copy link
Contributor

You could always new up an instance of JsonResult:

public  IActionResult OnPost(){
    return new JsonResult(...);
}

@mkArtakMSFT
Copy link
Contributor

Thank you for your feedback.
We're closing this issue as the behavior discussed seems to be by design.

@rishabhack
Copy link

thanks @Eilon ,@pranavkm

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