I have some trouble with logout on my page. i have a controller with this
public ActionResult LogOut()
{
FormsAuthentication.SignOut();
Session.Abandon();
return RedirectToAction("Index", "Home");
}
And so a view called LogOut. I've put an href on it with a button :
<li><a class="logout" href="~/Views/Account/LogOut.cshtml">Se déconnecter</a></li>
but when i click it keeps saying me your page couldn't been found etc...
But strange thing is this, if i put in my adress bar, the path to the LogOut view it works and i'm disconnected, someone knows why ?
You should give href like this instead of path to cshtml file:
<li><a class="logout" href="#Url.Action('Logout', 'ControllerName')">Se déconnecter</a></li>
it will hit LogOut Action Method then will Render your view Appropriately
You can set link in different way :
1) <li><a class="logout" href="/Account/LogOut">Se déconnecter</a></li>
2) <li><a class="logout" href="#Url.Action("LogOut","Account")">Se déconnecter</a></li>
3) <li>#Html.ActionLink("Se déconnecter", "Account", "Logout", new { #class="logout" })</li>
Related
All my page nav links are working but my Index nav is not working. When i try opening from any of my page links, it throws me this
404 Not Found
this is my index code for the nav
<a href ="index" >Home</a>
this is my route
Route::get('/', function () {
return view('index');
});
How to fix this problem?
try:
In view:
Home
In routes:
Route::get('/', function() {
return view('index');
})->name('index');
Your route URI is (/), So your anchor should be :
<a href="/" >Home</a>
href="index" call the /index, but you did not define it, so you will get a 404 error.
Alternatively, you can make a name route by name('index'), like this :
Route::get('/', function() {
return view('index');
})->name('index');
Then you can call from anchor link like this :
Home
As i html with Router link of Angular 4 how can i set Router in that of backboneJS
html is mentioned below
<ul role="menu" class="sub-menu">
<li><a [routerLink]="['/orderHistory']">History</a></li>
<li><a [routerLink]="['/userprofile']">Profile</a></li>
<li><a [routerLink]="['/addressbook']">Address Book</a></li>
<li><a [routerLink]="['/preferences']">Preferences</a></li>
<li><a [routerLink]="['/wishlist']">Wishlist</a></li>
</ul>
I am using backboneJs and Handlersbar any suggestions or good approach would be so useful. Thanks in advance.
I have to make footer and header in my application.
You can just set the href of <a> as normal hash like:
<li>History</li>
or if your app supports push state, without the hash like:
<li>History</li>
and set up and instance of Backbone.Router as mentioned in the docs.
This router instance will listen to changes in url and invoke the callbacks you define while instantiating the backbone router.
You can do following in your backbone.js View
events: {
'click a': 'changeRoute'
},
changeRoute: function(e) {
e.preventDefault();
var href = $(e.currentTarget).attr("href");
router.navigate(href, true);
}
Im trying to create a link in a view of AngularJS application just to send a data-method DELETE.
My route:
app.delete('/logout', function(req, res) {
req.session = null
res.status(200)
res.redirect('/')
})
My PugJS template:
a(ng-href='/logout', data-method='delete', data-confirm='Are you sure?', rel='nofollow')
span(translate) Logout
The HTML generated:
<a ng-href="/logout" data-method="delete" data-confirm="Are you sure?" rel="nofollow" class="" href="/logout">
<span translate="translate" class="ng-scope">
<span class="ng-scope">Logout</span>
</span>
</a>
But when I follow the link I receive the follow message:
Cannot GET /logout
It's looks to me that the data-method isn`t working. Does some one know what is happening?
Thanks for while.
I suppose you are used to use data-method with Rails. In AngularJS (or HTML), there is no such thing as data-method.
My suggestion is to either write your own directive to send the delete, or to add an action in your controller and use ng-click instead.
I am having trouble with accessing a html page that is in the same folder directory and level. Every thing I tried results in a error on the page. I have tried a few ways to navigate to the page, but all fail except for main 5 it just opens the login page again so that does not work either.
I am a bit lost on how this works. I have attached a picture of now my structure is set up below.
I am trying to get from home.html to main.html
I am running Spring framework.
And this is the code that I am using to as the link.
{{>partials/header}}
<h2>Login Page</h2>
<h4>Links</h4>
<ul class="nav nav-pills nav-stacked">
<li role="presentation">
Main 1
Main 2
Main 3
Main 4
Main 5
</li>
</ul>
{{>partials/footer}}
Here is my controller
//New login page
#RequestMapping(value = HOME_URL_MAPPING)
public String inventory(final Model model) {
return controllerHelper.createUrl(INVENTORY, WebGlobals.HOME);
}
//new page Was the home page before
#RequestMapping(value ="/main")
public String inventgus(final Model model) {
UserDetails activeUser = (UserDetails)SecurityContextHolder.getContext().getAuthentication().getPrincipal();
model.addAttribute(CAN_MAKE_REQUEST, canMakeRequest(activeUser));
model.addAttribute(CAN_APPROVE_REQUEST, canApproveRequest(activeUser));
return controllerHelper.createUrl(INVENTORY, "main");
}
You were so close! Here's the answer:
Main
The single dot refers to the current folder and putting a slash means that the file is under that folder.
this works for me:
Main
I have the following code in Controller:
class Home extends CI_Controller
{
function __construct()
{
parent::__construct();
$this->load->helper('url');
$this->load->library('home');
}
function index()
{
$this->load->view('layout');
}
function about()
{
$this->load->view('about');
}
}
If I want to create a relative link to about, how do I accomplish that? The following link in view doesn't always work. What is apporpiate way to about relative links in CodeIngiter?
<li> About </li>
I believe that the reason your view code doesn't work is most likely due to not autoloading the URL Helper.
If you add the 'url' to the Autoloader (http://ellislab.com/codeigniter/user-guide/general/autoloader.html) the function site_url will become available on all controllers, views, and models.
File to edit: application / config / autoload.php
Line 110
Example of what it should look like (assuming you aren't auto-loading any other helpers):
$autoload['helper'] = array('url');
link should be name_of_controller/name_of_the_function
<li> About </li>
try this
<li> About </li>
Auto load your url helper and try
<li> About </li>
You want the anchor() function.
http://ellislab.com/codeigniter%20/user-guide/helpers/url_helper.html
<li><?php echo anchor('home/about', 'About') ?></li>
Use that in your view.
Updated