Url.Action alternate in razor page view model class - asp.net-core-mvc

What can be used to get the URL of the page which is in this path of the project <website>/Pages/Account/Logout.cshtml
This is using view model razor pages and not mvc controller/action
When I use Url.Action("/Account/Logout", new { logoutId = ogoutId }); it says cannot resolve action /Account/Logout

In Razor Pages, you could use #Url.Page.
Logout
Or use asp-page directly,see more usage here.
<a asp-page="/Account/Logout" asp-route-logoutId ="1">Logout</a>

Related

Handling multiple views controllers in CodeIgniter 4

I am new to CodeIgniter 4.
I have one controller named Pages and helps to display website pages normally. Then I have another controller named Admin which is suppose to load the admin view with its own header and footer files.
While Pages controller works fine, the Admin controller keeps saying 404-file not found admin.
I think I have a problem with my current Route settings below. Please help.
$routes->setDefaultController('Pages');
$routes->setDefaultMethod('default');
// Route Definitions
$routes->get('/', 'Pages::index');
$routes->get('(:any)', 'Pages::default/$1');
try ajusting your code like this.
$routes->setDefaultController('Pages');
$routes->setDefaultMethod('default');
// Route Definitions
$routes->resource('pages');
$routes->get('/', 'Pages::index');
$routes->get('(:any)', 'Pages::default/$1');

AdxStudio: How display an entity form in Web template(Liquid Templates)

I am trying to display an entity form in a adxStudio web template, found one link Using Liquid to display EntityForm
<div class="container">{% entityform name:'My Entity Form' %}</div>
but this did't work for me.
Please help me to put an entity form on web template in adxstudio.
Thanks in advance......
Solved It!
Initially I am trying to display the web template with footer web template of home page, which did't work.
For displaying Entity form We need to:
Place the Entity Form in Web template like <div class="container">{% entityform name:'My Entity Form' %}</div>
Associate the Web template to a Page template
Page template needs to associate to a Web page
Browse the page, finally you will see/submit your form.
Thanks!

Dynamic nested master page in ASP.net MVC Razor

I've got some views that share a master page and I want to programatically set the master page for the master page. Is it possible to do this? How do I get a reference to the master of a master?
Cheers, Ian.
Return layout page file as part of model. and specify the LayoutPage property from the model as follows:
#{
LayoutPage = ViewBag.LayoutPage;
}
Please refer following link for basic razor layout page concepts
Layout/Master pages using Razor

NotFound Controller on mvc website

On A c# mvc website, I created a controller with the name NotFound, and then created a default route to an index action on the controller. When I debugged the program it went to the correct controller action but did not display anything in the view. Does any one know why?
did you do:
return View("some view name");
in the action method?
what does the some view name.aspx contain?

How can I create a login partial view in MVC?

How can I create a login partial view in MVC 2.0?
I want to include this in several masterpages in my site since I can't use the login control in MVC.
What code do I put in the controller which will accept the username and password?
The default MVC project creates one for you. Just install MVC and create a MVC project. It will have a Master page, with a login partial view already created.

Resources