maxtoroq / mvcpages Goto Github PK
View Code? Open in Web Editor NEWMvcPages combines the simplicity of ASP.NET Web Pages with the power of ASP.NET MVC
License: Apache License 2.0
MvcPages combines the simplicity of ASP.NET Web Pages with the power of ASP.NET MVC
License: Apache License 2.0
This is more of a stupid question than an issue, but I'm not sure how to define the OutputCache either at a default level or for individual .cshtml pages.
Putting OutputCache attributes on controllers works as expected, I'm just not sure how it would work to insert as a directive in a .cshtml page.
Hi,
I tried using MvcPages with MVC5, and found the following error:
Inheritance security rules violated by type: 'MvcPages.MvcPage'. Derived types must either match the security accessibility of the base type or be less accessible.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.TypeLoadException: Inheritance security rules violated by type: 'MvcPages.MvcPage'. Derived types must either match the security accessibility of the base type or be less accessible.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[TypeLoadException: Inheritance security rules violated by type: 'MvcPages.MvcPage'. Derived types must either match the security accessibility of the base type or be less accessible.]
System.Reflection.RuntimeAssembly.GetType(RuntimeAssembly assembly, String name, Boolean throwOnError, Boolean ignoreCase, ObjectHandleOnStack type) +0
System.Reflection.RuntimeAssembly.GetType(String name, Boolean throwOnError, Boolean ignoreCase) +41
System.Reflection.Assembly.GetType(String name) +14
System.Web.WebPages.Razor.RazorBuildProvider.GetGeneratedType(CompilerResults results) +235
System.Web.Compilation.BuildProvider.CreateBuildResult(CompilerResults results) +72
System.Web.Compilation.BuildProvider.GetBuildResult(CompilerResults results) +16
System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath) +9881921
System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) +299
System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) +103
System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean throwIfNotFound) +165
System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp) +43
System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(String virtualPath, Type requiredBaseType) +28
System.Web.WebPages.BuildManagerWrapper.CreateInstanceOfType(String virtualPath) +343
System.Web.WebPages.VirtualPathFactoryExtensions.CreateInstance(IVirtualPathFactory factory, String virtualPath) +236
System.Web.WebPages.VirtualPathFactoryManager.CreateInstanceOfType(String virtualPath) +261
System.Web.WebPages.VirtualPathFactoryExtensions.CreateInstance(IVirtualPathFactory factory, String virtualPath) +132
System.Web.WebPages.WebPageHttpHandler.CreateFromVirtualPath(String virtualPath, IVirtualPathFactory virtualPathFactory) +58
System.Web.WebPages.WebPageHttpHandler.CreateFromVirtualPath(String virtualPath) +59
System.Web.WebPages.WebPageRoute.DoPostResolveRequestCache(HttpContextBase context) +462
System.Web.WebPages.WebPageHttpModule.OnApplicationPostResolveRequestCache(Object sender, EventArgs e) +157
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +136
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +69
Any ideas on how to resolve this?
Thanks,
Brian
This is a common pattern I use to generate links without hard-coding the page's name:
string page = VirtualPath.Split('/').Last().Split('.').First();
string id = UrlData[0];
<a href="@Href(page, id)">...</a>
It would be useful to have a PageName property for this purpose.
This is because HtmlHelper<>
creates a copy of ViewData
. The workaround is:
Model = Html.ViewData.Model = new MyModel();
Hi max. As i already said in the disqus of your site i'm stuck with this error.
For example: in the ChangePassword you use this code:
if (IsPost
&& TryUpdateModel()
&& ChangePassword(Model)) {
and everthing works fine. Now, let's suppose i want to specify which properties of the model i want to include in the binding(for ex. jsut username). If I understand correctly I should write something like
if (IsPost
&& TryUpdateModel(Model, includeProperties: new string[]{"username"})
&& ChangePassword(Model)) {
Is that correct?
But in this case i get the argumentnullexception because model in null.
What am I doing wrong? Can you give an example of working code for this case?
Thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.