Hi
New to ASP.NET Zero so apologies if a basic / stupid question.
Currently when I run project it goes to the login page (if use not already logged in), I instead want it to go to a "welcome" page which shows information about my site and where I would then have a login button for users to login and go to the main site using the Zero layout etc.
So main page wouldn't have sidebar or anything it would just have custom Bootstrap CSS to show logo, site information and a login button etc.
I know there is a .Web.Public project, but a) this is outdated and b) I was hoping to do it in a simpler way than having a separate public project just for one initial page.
Hope this make senes, if not please ask what needs to be clarified.
Thank you all
13 Answer(s)
-
0
Hi wingers
*.Web.Public project has been updated with this issue. This change will be reflected in v14.0. By applying the changes here, you will be greeted with a more updated interface. Or, if your project is MVC, you can create a page and change the opening page orientation in
HomeController
. If Angular, you can change the start page inapp-routing.module.ts
. Changes here will redirect you to this page for the first time. -
0
Thanks for reply.
My project is MVC.
I created a new controller (.Web.Mvc\Areas\App\Controllers\StartupController.cs) and a new page (.Web.Mvc\Areas\App\Views\Startup\Index.cshtml), but can't see to work out how to change the HomeController to load that new page first correctly as currently HomeController has [AbpMvcAuthorize] and code to check various criteria as to what page to load, even removing the [AbpMvcAuthorize] and setting it to just my page didn't work for me as initially got error. Comments please?
-
0
Hi wingers
Here, you will need to make changes not to the controller in the Area section, but to the
HomeController
in the controller in the main. As stated belowpublic class HomeController : MvcDemoProjectControllerBase { // public async Task<IActionResult> Index(string redirect = "", bool forceNewRegistration = false) { if (forceNewRegistration) { await _signInManager.SignOutAsync(); } if (redirect == "TenantRegistration") { return RedirectToAction("SelectEdition", "TenantRegistration"); } return AbpSession.UserId.HasValue ? RedirectToAction("Index", "Home", new { area = "AppAreaName" }) : RedirectToAction("WelcomePage", "Home"); // You can specify it on the application opening page } public IActionResult WelcomePage() { return View(); }
-
0
Thank you for your response.
So I have added my new page and its controller as documented in previous reply - called Startup.
I have now edited the correct HomeController.cs as below, but when running I get error as below about not being logged on, but the whole point is I don't want to have to be logged on to see this first page
using System.Threading.Tasks; using Abp.Runtime.Session; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; using PCADemo.Identity; using PCADemo.Web.Controllers; namespace PCADemo.Web.Controllers { public class HomeController : PCADemoControllerBase { private readonly SignInManager _signInManager; public HomeController(SignInManager signInManager) { _signInManager = signInManager; } public async Task<IActionResult> Index(string redirect = "", bool forceNewRegistration = false) { if (forceNewRegistration) { await _signInManager.SignOutAsync(); } if (redirect == "TenantRegistration") { return RedirectToAction("SelectEdition", "TenantRegistration"); } return AbpSession.UserId.HasValue ? RedirectToAction("Index", "Home", new { area = "App" }) : RedirectToAction("Index", "Startup", new { area = "App" }); // You can specify it on the application opening page } public IActionResult WelcomePage() { return View(); } } }
-
0
Hi wingers
The problem here is that you use
_Layout.cshtml
found in the App. You can create a separate layout for the start page. -
0
Okay thanks, rearrange my code and now have it working.
One final question - when logging out how can I have it redirect back to my startup page rather than going back to /Account/Login
-
0
Hi wingers
You can change the
RedirectToAction
value of the Logout method in theAccountController
in main. -
0
Perfect, thank you very much
-
0
We're glad we could help, good work.
-
0
one final question relating to the login page. How do I change the background image?
I assume I could replace login.png and login-dark.png in *.Web.Mvc\wwwroot\metronic\assets\media\svg\illustrations
But also assumed I could edit path in *.Web.Mvc\Views\TenantRegistration_Layout.cshtml, but this method doesn't work?
-
0
-
0
perfect thanks
-
0
You're welcome, good work.