1

I am trying to get my nopCommerce 3.50 site to open a specific page when the site is visited.

When I debug the project locally it works correctly as I have the specific page 'welcome.html' set as the start action in the project properties (in Visual Studio 2012). However once the site is published on the server it ignores this request.

In IIS I have checked that 'welcome.html' is at the top of the list of default pages, however nopCommerce ignores these settings (as found on various forums) and even if you delete everything else it always goes to default.aspx.

I've tried adding this to the web.config in system.webserver and this has made no difference:

<defaultDocument>
                <files>
                      <add value="Welcome.html"/>
                  </files>        
  </defaultDocument>

There is no other reference to a default starting page in the config.

I'm not too familiar with nopCommerce or the routing, does anyone know how/where I can change the default page? Everything I have found on the forums so far has not worked. And yes, I have rebuilt the project after each change, usually completely replacing the bin folder on the server to make sure.

I don't want the site to redirect to a specific action or view, but to a static HTML document in the root folder of the project (well I don't want that either really but the client has been very specific about what they want). The static page has two buttons, one that will go to the nopCommerce default.aspx and one that goes to another site.

Thanks

Lyall
  • 1,367
  • 3
  • 17
  • 42

2 Answers2

1

Found a way round it to meet the requirements:

  1. Add a new folder into the directory ('NOP' for example) and put everything apart from the welcome.html page inside the new folder.
  2. Change the links in the welcome page to point inside the new folder structure (images, links etc.).
  3. In IIS make sure that welcome.html is set as a default document, and as it is now the only document in the folder it loads correctly.
  4. In IIS convert the new folder into an application (right click > 'convert to application' on Windows Server 2012 R2)

This way no changes are needed to the code in nopCommerce and the desired result is achieved.

Lyall
  • 1,367
  • 3
  • 17
  • 42
1

you can change the route in the global.asax.cs

Default route is

  routes.MapRoute(
                "Default", // Route name
                "{controller}/{action}/{id}", // URL with parameters
                new { controller = "Home", action = "Index", id = UrlParameter.Optional },
                new[] { "Nop.Web.Controllers" }
            );

This route will tell you execute in the HomeController, there is Index action (function) and return the view defined with the same name under the Views. View path will be Views/Home/Index

In order to change that you should add a welcome function (just copy the Index function and rename with welcome and paste it into the HomeController).

then you can change your routing as bellow.

 routes.MapRoute(
                    "Default", // Route name
                    "{controller}/{action}/{id}", // URL with parameters
                    new { controller = "Home", action = "Welcome", id = UrlParameter.Optional },
                    new[] { "Nop.Web.Controllers" }
                );

Dont forget to create your Welcome view under Views/Home as Welcome.cshtml

Emil
  • 6,411
  • 7
  • 62
  • 112
  • Thanks for the answer but it doesn't address the part in the question 'I don't want the site to redirect to a specific action or view, but to a static HTML document in the root folder of the project'. However if it wasn't for this specific (stupid) requirement your answer is very helpful and I'm sure will be useful for me under normal circumstances, so thank you :) – Lyall Oct 22 '15 at 15:32
  • @Lyall This can be general MVC question. eventually cshtml files are generating html on the client side, it is just called cshtml on server side. you may check this url. http://stackoverflow.com/questions/22656945/set-index-html-as-the-default-page – Emil Oct 22 '15 at 16:09
  • Good point, and I've also realised that what I was intending to do is impossible. The workaround I have found (the answer I posted) works for this specific example but anyone else wanting to change the default page (i.e. looking at the subject of this question) would be able to follow your answer and achieve what they want. – Lyall Oct 22 '15 at 17:25