How do you include .html or .asp file using razor?

后端 未结 14 1527
说谎
说谎 2020-12-14 01:09

Is it possible to use server side include in Razor view engine to include .html or .asp file? We have an .html file and .asp files that contain website menus that are used

14条回答
  •  醉酒成梦
    2020-12-14 01:30

    Razor does not support server-side includes. The easiest solution would be copying the menu markup into your _Layout.cshtml page.

    If you only needed to include .html files you could probably write a custom function that read the file from disk and wrote the output.

    However since you also want to include .asp files (that could contain arbitrary server-side code) the above approach won't work. You would have to have a way to execute the .asp file, capture the generated output, and write it out to the response in your cshtml file.

    In this case I would go with the copy+paste approach

提交回复
热议问题