-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Using "page" route parameter in convention routing fails with Asp.Net Core Mvc 2.0 #6660
Comments
Can you show the exception? PS: There are a bunch of things that can be cleaned up with your code in general but I'll discuss those after we figure out why your views can't be found. |
One more thing, I'd suggest turning up the logging verbosity. That should show you exactly what's happening. |
@davidfowl: Here ya go:
|
@eat-sleep-code See my other suggesting about turning up the logging verbosity. |
@davidfowl Can that be done through the config? If it requires a rebuild, I will have to wait until later as I am in the office now and the code for this site is at home. |
@eat-sleep-code It can be done through configuration in 2.0.0 but you didn't update your code to use any of the new APIs. I'm assuming you also have views in the right folder? Can you show the layout on disk? Are you running behind IIS? |
@davidfowl Do you have an outline of what code changes need to made to use the new APIs? Yes it is behind IIS. (Windows Server 2016 Datacenter) When I switched the DLL references in my project, I suddenly get a Framework.PrecompiledViews.dll file instead of the /Views folder. This route, should (and used to) make it work.
|
@eat-sleep-code https://docs.microsoft.com/en-us/aspnet/core/migration/1x-to-2x/ Just to be clear, I'm not saying this is the reason for any failures. It's more about enabling logging by default (and the ability to change it via configuration).
Yes, this is one of the new defaults. Any clues if anything here needs to be changed @pranavkm ? |
@davidfowl Thanks for that migration reference. I will have to tackle that stuff tonight. But you are right, nothing there seems to explain why the silly routes are not working. |
@eat-sleep-code could you include a file list |
@eat-sleep-code - sorry, I was specifically looking for the apps Views directory which is missing here. |
@pranavkm Yeah, doesn't get created. Instead I have the Framework.PrecompiledViews.dll. |
I was looking for the views directory in your application root (not the output). Alternatively if you could share your application that would also work. |
@pranavkm I will provide a repo tonight when I get home. |
@pranavkm Invited you to the private repo I created with all the entire project. |
Thanks. I missed this when I was reading your initial issue. The route template you are using
services.AddMvc().AddViewLocalization().AddDataAnnotationsLocalization().AddRazorOptions(options =>
{
options.ViewLocationExpanders.Remove(options.ViewLocationExpanders.First(f => f is Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageViewLocationExpander));
});
@rynowak, am I missing something a more obvious solution? Would we need to do anything additional to specifically address this breaking behavior? |
@pranavkm Just confirming, I would need to complete both steps to fix this correct? |
@eat-sleep-code doing either one of these should fix your issue. |
@pranavkm Thanks! This appears to have fixed this issue. This probably should be at least documented somewhere to help out other folks who might encounter this scenario. PS: I took option 1 since I am not using RazorPages. Option 2 seemed to wreak some havoc on my paging module as it seems to expect "page" not "pageId" (but otherwise Option 2 would have worked fine at fixing my issue). |
@pranavkm isn't this a breaking change? |
I'm having a similar issue, but not using precompiled views. My generic area routes like
are not. The crazy thing is that the actions are being executed, it just can't find the view, and appears to only look in shared locations:
These functioned as expected in v1.1. In the above example, the view is absolutely in |
That did it. That's an unfortunate bug. Thank you for your help, everyone! |
Good job I found this thread:) |
I have the same bug but your solution doesn't fix it
this issue happen because i'm using tag helper
if i changed page to pageid the url Community/Page3 display page1 |
Hi I have the same issue with routing. The following code worked, but the result looks like this: http://localhost:51409/?page=2, which is not ideal but when I add {page} variable into Template as following: then the view List is not found. Can anyone help me out? Thank you! |
Change route name “page” to something else |
Hi Davidfowl Thank you for your response. I have change variable "page" to "pg" as following. public ViewResult List(string category, int pg = 1) routes.MapRoute( it still didn't work. Do you think it is a bug in ASP Net Core 2.0? FYI, I started a web app project using empty template. Thank you! |
Hi, I have the same problem BIngZL1983...(( use ASP Net Core 2.0, but i resolved problem change parametr "page" in routes.... =) |
@Temoxa, the issue was fixed as part of the 2.0.3 release. Upgrading your package reference - |
Today upgrade to 2.0.3 , but problem saves....( |
I see a similar issue, but related to using
Using this, The problem first showed up when using As suggested, changing this to something like |
@Temoxa could you file a new issue that details the issue you're running in to? |
My problem is resolved in version 2.0.3 |
I have a website that was working perfectly fine in .NET core 1.1.
Today -- with the release of .NET Core 2.0 -- I decided to update my application. I changed my Target Framework to .NET Core 2.0, and switched over to using the Microsoft.AspNetCore.All package as outlined here: https://blogs.msdn.microsoft.com/webdev/2017/08/14/announcing-asp-net-core-2-0/
I installed the .NET Core 2.0 Runtime on my server. I restarted my server.
The application builds fine, but when I deploy, it seems my routes -- which worked perfectly in .NET Core 1.1 -- no longer work.
When I try using https://example.com/history (desired URL, which the route SHOULD direct to the "History" action of the "Pages" controller) it complains of a missing View.
If I use https://example.com/pages/history (not desired URL) it loads the home page, not the history page.
Again, this worked fine in .NET Core 1.1
This is my /Program.cs:
This is the portion of my /Startup.cs with the routes defined at the end:
The text was updated successfully, but these errors were encountered: