NopCommerce version: 3.9
I've designed a web store using NopCommerce 3.9. Any code I added is in a plugin.
The store uses a front page that can be found in the plugin. It relies on a route called 'home' in a RouteProvider class in the plugin. It does not complain about that route, instead it complains about a route named 'RegisterVendor' found in the same file. Here are both routes
routes.MapRoute("home",
"",
new { controller = "AoiVendorsHome", action = "Index" },
new[] { "Nop.Plugin.Other.AoiVendors.Controllers" });
routes.MapRoute("RegisterVendor",
"register/designer",
new { controller = "AoiExchange", action = "RegisterVendor" },
new[] { "Nop.Plugin.Other.AoiVendors.Controllers" });
The plugin installs properly and everything works exactly as expected on my local machine.
The problem is after deploying to the web it can't find the route. Here is a imgur link, follow it to see the error
Restarting the server fixes the error for a while, but it does eventually come back. It also comes back any time I redeploy without restarting the server afterwards.
Does anyone have any ideas?
Thank You.
The "HomePage" route of nopCommerce is registred this way
//home page
routes.MapLocalizedRoute("HomePage",
"",
new { controller = "Home", action = "Index" },
new[] { "Nop.Web.Controllers" });
Check your load order: If your registration does not hit first, remove nopCommerce "HomePage" route and add yours or add yours first using the Priority property of IRouteProvider.
MVC uses the route that first matches the request.
Regarding the deployment problem, make sure your plugin is deployed to ~/Plugins/{yourPluginFolder} and not the bin folder of Nop.Web. Plugin in ~/bin folder can be loaded but without guarantee.
I was able to fix the issue by selecting the 'Remove additional files at destination' checkbox under file publish options on the settings tab in the publish popup dialog in visual studio. I imagine an older file was not being overwritten and was causing problems.
Related
It seems every time I try and deploy a plugin to Umbraco 9 on Azure App Service I seem to end up with an Angular error where the plugin's controllers don't get registered something like this
Error: [$controller:ctrlreg] http://errors.angularjs.org/1.8.0/$controller/ctrlreg?p0=Our.Iconic.Prevalues.Packages
at umbraco-backoffice-js.js.vd671f7279661e0e87e3549a36c6c11bb1054da05:32:168
at umbraco-backoffice-js.js.vd671f7279661e0e87e3549a36c6c11bb1054da05:123:19
at ea (umbraco-backoffice-js.js.vd671f7279661e0e87e3549a36c6c11bb1054da05:105:20)
at p (umbraco-backoffice-js.js.vd671f7279661e0e87e3549a36c6c11bb1054da05:96:476)
at g (umbraco-backoffice-js.js.vd671f7279661e0e87e3549a36c6c11bb1054da05:90:292)
at umbraco-backoffice-js.js.vd671f7279661e0e87e3549a36c6c11bb1054da05:89:422
at Object.link (umbraco-backoffice-js.js.vd671f7279661e0e87e3549a36c6c11bb1054da05:326:432)
at umbraco-backoffice-js.js.vd671f7279661e0e87e3549a36c6c11bb1054da05:42:134
at Ca (umbraco-backoffice-js.js.vd671f7279661e0e87e3549a36c6c11bb1054da05:114:361)
at p (umbraco-backoffice-js.js.vd671f7279661e0e87e3549a36c6c11bb1054da05:98:340) '<div ng-include="propertyEditorView">'
When you click on that angular link it just says
The controller with the name 'Our.Iconic.Prevalues.Packages' is not registered.
Everything works perfectly fine on my local environment and when I connect to the Azure App Service all the files are there in the App_Plugins... folder. It even loads some of the other files in the manifest but for some reason the controllers don't get registered. This is not the first plugin where this has happened either. Last time I manually deleted / copied files / redeployed / restarted / stood on one foot and eventually it started working. No idea what fixed it. Now next package added same thing happens again. What am I missing?
Had the same issue and got it to work with the solution provided here:
https://our.umbraco.com/forum/umbraco-9/107740-umbraco-9-cant-register-controller-for-a-custom-dashboard-that-works-locally-but-fails-when-deploy
Just want to add that this section should be added in Umbraco > CMS section of appsettings like so:
"Umbraco": {
"CMS": {
"RuntimeMinification": {
"useInMemoryCache": true,
"cacheBuster": "Timestamp"
}
}
}
I'm trying to publish my ASP.NET Core application on Azure service. This works, but when I try to use the application functionality, I get the message
Your App Service app is up and running.
Moreover, in my wwwroot folder I don't have any .html files. I only have an Index.cshtml file, which is located in the Views/Home-folder in my application, all another files are .css, .js, etc.
When I run the application in Visual Studio in Debug mode, immediately opens the page in browser that was generated from Index.cshtml. But after the application is published in Azure, this does not happen.
What can I do to make Azure see Index.cshtml?
AFAIK, a default route would be added to Configure method of your Startup.cs file as follows:
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
I also created my .Net Core 2.0 MVC application to check this issue, it could work as expected on local side and my azure web app.
Moreover, in my wwwroot folder I don't have any .html files.
Views under Web Application and Web Apllication MVC would be compiled into {your-webapplication-assemblyname}.PrecompiledViews.dll, you could leverage ILSpy to check your DLLs.
For your issue, I would recommend you clear the web content in your web app via KUDU, or modify the publish settings and choose Remove additional files at destination under File Publish Options, then redeploy your application to Azure Web App to narrow this issue.
Are you finding index.cshtml in your web package? In case if you get index.cshtml in your final web package, you may need to add index.cshtml file type to the following in..
..YourAzureWebApp --> Application Settings --> Default Documents
I found out what the problem was. There are two types of applications, as presented below in the picture: Web Application and Web Apllication MVC. I worked with the second type of application. When I selected the first type and published the application, Azure immediately found the required index.html. I just had to choose Web Application.
But why does not it work with the second type of application (Web Apllication MVC)? I still do not know the answer to this question.
2 cents from my side as I just stuck for a while with this.
The problem was that yesterday I'd been playing around with deploying to Ubunut / Ngnix and today I decided to try Azure.
BUT I forgot to comment (disable) the following lines in my Startup:
//for nginx server
app.UseForwardedHeaders(new ForwardedHeadersOptions
{
ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
});
and that costed me almost half of the day to find the issue.
I also put the routing in the following way
app.UseStatusCodePages();
app.UseAuthentication();
app.UseMvc(routes => {
routes.MapRoute(
name: "default",
template: "{controller=Pages}/{action=Index}");
});
Now looks like it works on Azure :)
Does anyone encountered this kind of problem? I think it has something to do with the IIS or so... I am using IIS 10 also using VS2017 and ASP.NET Core. When I launch the application I saw this error:
This localhost page can’t be found
No webpage was found for the web address: http://localhost:44306/
I tried changing the port. But nothing works.
I tried other application it works but only this project having this kind of error and I don't know why.
Any Idea how to fix this?
Update:
I solved this problem when I realized I had accidentially removed the default route in the StartUp class' Configure method:
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
This is similar to #ToMissTheMarc answer, but shows how to define routes in .Net Core version 3.0
I was having a similar problem when trying to hit my API endpoint https://localhost:44380/api/Restaurants
In order to map my routes for an API controller class that inherited from the ControllerBase class, I needed to add the line endpoints.MapControllers to Configure method of Startup.cs class, as follows:
//Pre .NET core 3.0 way of doing things
//app.UseMvc(routes => {<some routing stuff here>});
//.NET core 3.0 way
app.UseRouting();
app.UseEndpoints(endpoints =>
{
endpoints.MapRazorPages(); //Routes for pages
endpoints.MapControllers(); //Routes for my API controllers
});
If the answer above doesn't work or you're coming from the .NET Web API tutorial, this might help. So for me, I removed the launchUrl property from launchSettings.json because I wanted to use a static page (per the instructions of the tutorial I'm following) and forgot to add 2 lines in my haste. I finally went back and looked over it and this solved my issue.
Open the Startup.cs file and inside public void Configure... add the following above the app.UseMvc(); line:
app.UseDefaultFiles();
app.UseStaticFiles();
I faced the same problem but the mistake was a silly one hence the solution very easy!
there was a typo in my route
I added a space by mistake after Controller Name
I know its not very Technical Answer but it won`t harm to double check
was:
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute("Default", "{controller= Home}/{action=Index}/{id?}");
});
Corrected to:
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute("Default", "{controller=Home}/{action=Index}/{id?}");
});
Had the same problem, it turned out I unintentionately changed my Index() method of HomeController to property through refactoring
public ViewResult Index() => View()
became
public ViewResult Index => View();
In my case, I modify the index name to HomePage, and I resolve it by check several places:
(You can search index in your entire solution to check)
In Views/_Layout.cshtml
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="HomePage">xxx</a>
In Startup.cs
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=HomePage}/{id?}");
});
In Controllers/HomeController.cs
public IActionResult HomePage()
{
return View();
}
After I edit the three places, it works well.
Make sure project, lauchsettings.json ports are set correctly.
if this is happening you are missing wwwroot folder.
This was happening to me because I had copied a .net core 1 Razor Page into my .net core 2.2 project. I added a #page declaration to the Razor Page and everything worked. Just adding this here because this is the first Google result for this issue.
Be sure to check and try these items:
Change port number in project properties.
Reset IIS in cmd using "iisreset" command.
Checked the StartUp.cs to ensure
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
});
Restarted VS and laptop but to no avail too.
Checked launchSetting.json but everything is correct.
In my case it was just switching to another localhost's port that ISS provided while launching. On the first one there was an error "page not found" but second one worked as it supposed to.
In your project, go to properties -> launchSettings.json (double click)
in iisSettings -> iisExpress -> applicationUrl (change the port number for your localhost)
and try again, issue should be solved successfully.
This happens every time I add a razor page to my project.
The solution is to, in Visual Studio, click on the cshtml file and then set "Build Action" from "None" to "Content". Fixes the issue every time (for me).
I crated area/modular MVC5 application according to this tutorial:
This
it worked perfectly on local. but i got 404 error, when i deployed project on iis and clicked on specified area link.
and i didn't find any solution for that.
The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
Requested URL: /Sale
and this is my action links which are perfectly working on local run:
#Html.ActionLink("Sale","Index","Sale",new { Area="Sale"},null)
edited:
public class SaleAreaRegistration:AreaRegistration
{
public override string AreaName
{
get
{
return "Sale";
}
}
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapRoute(
"Sale_default",
"Sale/{controller}/{action}/{id}",
new { controller = "Sale", action = "Index", id = UrlParameter.Optional },
new string[] { "MVCPluggableDemo.Controllers" }
);
}
}
attention: according to the tutorial which i said in first line. i created my module project in another virtual project in solution(the real path is in area folder of main project like"~/ProjectName/Areas/"). but i think the publisher does't understand it...because i don't see any of my module views in deployed path.
its better to completing my help request by this obvious question:
How to deploy MVC project include areas, and the modules which are in areas folder?
Its simply obvious:
Check your page directory. The server cannot locate your the file,
it maybe in different folder.
Also try to Check this.
the main Reason of my problem was this:
VisualStudio doesn't include my Area folder, in publish path..why? i don't know
Solution: no solution yet!..but i added my module dll inside bin folder manually. and created my areas folder and his modules projects solution(dlls' are not not necessary) in main published solution, manually to ..
finally it worked, but i dont thing is the standard solution
I have a fresh grails 2.1.1 installation, windows 7.
Problem: Static resources (CSS) don't reload in development mode.
According to http://grails.1312388.n4.nabble.com/Re-Grails-2-0-CSS-Changes-not-Picked-Up-td3680479.html I've tried in Config.groovy:
environments {
development {
grails.resources.processing.enabled = false;
}
}
Result: no CSS is loaded at all. Chrome needs 30 seconds to load a page, and does not load any CSS.
I reverted that change.
Then, according to http://grails.1312388.n4.nabble.com/disabling-static-resource-stuff-td3827384.html
I've tried to uncomment the plugins runtime ":resources:1.1.6"
Now I'm back to how it was initially, CSS files are served but not reloaded.
What works temporarily is the hack mentioned here:
http://grails.1312388.n4.nabble.com/The-resources-plugin-is-not-reloading-my-CSS-and-JS-of-a-bundle-td3857137.html
Top append to the url: ?_debugResources=y
How do I make static resources being reloaded in development mode? Shouldn't that be the default anyway? It doesn't make any sense in my opinion to reload gsp's (which it does) but not the static resources.
I set the grails.resources.debug flag in Config.groovy on debug to get the URL to be appended like this
css/main.css?_debugResources=y&n=1386063248351
environments {
development {
grails.resources.debug = true
}
production {
}
}
Any URL in your application can have the query parameter _debugResources=y added to it, and the request will perform no processing. So for example if you are browsing http://localhost:8080/myapp/admin and need to bypass resources, just change the URL in your browser to http://localhost:8080/myapp/admin?_debugResources=y
Reference Link : https://grails-plugins.github.io/grails-resources/guide/8.%20Debugging.html