I need to create a function that is only necessary inside one cshtml file. You can think of my situation as ASP.NET page methods, which are min web services implemented in a page, because they're scoped to one page. I know about HTML helpers (extension methods), but my function is just needed in one cshtml file. I don't know how to create a function signature inside a view. Note: I'm using Razor template engine.
相关问题
- MVC-Routing,Why i can not ignore defaults,The matc
- Entity Framework throws exception - Network Relate
- parameters in routing do not work MVC 3
- Slow loading first page - ASP.NET MVC
- There is no ViewData item with the key 'taskTy
相关文章
- “Dynamic operations can only be performed in homog
- How to get a list of connected clients on SignalR
- How do you redirect to the calling page in ASP.NET
- Change color of bars depending on value in Highcha
- The program '[4432] iisexpress.exe' has ex
- ASP.Net MVC 4 Bundles
- How to get server path of physical path ?
- Cannot implicitly convert Web.Http.Results.JsonRes
If your method doesn't have to return html and has to do something else then you can use a lambda instead of helper method in Razor
Use
Then you can call the function like-
You can use the @helper Razor directive:
Then you invoke it like this:
why not just declare that function inside the cshtml file?
Take a look at Declarative Razor Helpers