我正在使用Visual Studio制作带有Areas中的子应用程序的MVC应用程序。在根_Layout.cshtml中,我有一个navbar-fixed-top,它将导航到不同的区域。我希望在每个视图中都能做到这一点。然后,我修改了CSS,以创建一个navbar-fixed-left,在该区域中,我将仅在特定区域内进行导航,并且每个区域都必须是唯一的,但必须用于该区域内的所有视图。
所以我的问题是,有没有办法在共享布局中使用共享布局,这样我就不会冗余复制并最终破坏顶部导航?
答案 0 :(得分:0)
您可以在_layout页面的html中使用const FindByEmail = async (jwt_payload, done) => {
// search for the user's ID by their email
try {
const email = jwt_payload.subject
request.input('email', email )
await request.execute('isAuthenticated', (err, docs) => {
if (err || docs.rowsAffected < 1) return done(err, false)
console.log('fired..')
return done(null, docs.recordset[0].ID) // send the User ID to the next middleware which in this case is Upload function
})
} catch (err) {
return done(err, false)
}
}
const cookieExtractor = (req) => req.cookies['jWtToken']
JWT_OPTIONS = {
jwtFromRequest: cookieExtractor,
secretOrKey: JWT_SALT
}
module.exports = {
authenticate: passport.authenticate('jwt', {
session: false
}),
JWT_OPTIONS,
JwtStrategy,
FindByEmail
}
app.post('/image', authenticate, upload, (req,res)=> console.log(req.body))
。
在离开导航的视图中,您可以填充
部分RenderSection('leftNavigation', false)
如果您具有对整个区域有效的导航,则可以在该区域的_viewStart.cshtml中使用@section leftNavigation
{
<ul>
<a href="">Some line</a>
</ul>
}
。