使用mvc,在startup.cs中有一个看起来像这样的部分:
pub struct DefaultResourcePack<'a> {
regions: [TexRegion; SHEET_TEX_ID_COUNT],
sheet: Sampler<'a, Texture2d>,
simple_program: Program,
texture: Texture2d,
}
impl<'a> DefaultResourcePack<'a> {
fn new<F: Facade>(facade: &'a F) -> DefaultResourcePack<'a> {
// construct regions
let sheet_dim: f32 = 16.0;
let slot_size: f32 = 1.0 / sheet_dim;
let mut regions = [TexRegion::new(0.0, 0.0, 0.0, 0.0); SHEET_TEX_ID_COUNT];
for &id in &ALL_SHEET_TEX_ID {
let slot = sheet_tex_ord(id) as f32;
let ord = sheet_tex_ord(id);
regions[ord] = TexRegion::uvwh(
(slot % sheet_dim) * slot_size,
(slot - (slot % sheet_dim)) * slot_size,
slot_size,
slot_size,
)
}
// construct the sheet
let image = image::load_from_memory(DEF_TEX_SHEET_BYTES)
.expect("texture sheet load error")
.to_rgba();
let image_dim = image.dimensions();
let image = RawImage2d::from_raw_rgba_reversed(&image.into_raw(), image_dim);
let texture: Texture2d = Texture2d::new(facade, image).expect("texture creation error");
let sheet: Sampler<'a, Texture2d> =
Sampler::new(&texture).magnify_filter(MagnifySamplerFilter::Nearest);
// construct the program
let simple_program = Program::new(
facade,
ProgramCreationInput::SourceCode {
vertex_shader: SIMPLE_SHADER_V,
tessellation_control_shader: None,
tessellation_evaluation_shader: None,
geometry_shader: None,
fragment_shader: SIMPLE_SHADER_F,
transform_feedback_varyings: None,
outputs_srgb: false,
uses_point_size: false,
},
).expect("GLSL compilation error");
// construct the pack
DefaultResourcePack {
regions,
sheet,
simple_program,
texture,
}
}
}
将控制器更改为帐户并执行登录操作会在重新启动网站后找不到错误404。我错过了什么吗?
答案 0 :(得分:0)
我首先要在Startup.cs中验证你的app.UseMvc(...)是否在你的Configure方法的末尾。然后验证您的控制器是否继承自Controller,并且您没有[Route]属性。
如果这些不解决,请查看示例音乐商店应用Startup.cs文件和sample controller,看看是否有任何遗漏。不幸的是,没有更多的信息可以猜测问题是什么。
答案 1 :(得分:0)
在AccountController中查找属性路由,如果它存在,它将与您的startup.cs路由选项一起崩溃,所以只需将其注释掉即可。