ASP MVC2 deploying to IIS 7 with error - asp.net

after I deployed the application to IIS7 server, it seems fine at the beginning and can display the login page. But after the user inputted the username and password, I have to authenticate the user with the DB connection. At this time, it display error (attached). I guess the error is caused by the reflection during the EntityFramwork load the DB data.
My server has been installed .net framework 3.5 sp1 already.
On the other hand, I have tried another server. If a server has been installed VS2008 and MVC2 package for VS2008, that server can run the application properly in IIS7.
My aim is to run the application on a IIS7 server with .net framework 3.5 only.
Please help me solve this problem.
The error datails:
Server Error in '/FDDV_demo' Application.
--------------------------------------------------------------------------------
Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
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.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
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:
[ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.]
System.Reflection.Module._GetTypesInternal(StackCrawlMark& stackMark) +0
System.Reflection.Assembly.GetTypes() +111
System.Data.Metadata.Edm.AssemblyCacheEntry.LoadTypesFromAssembly(LoadingContext context) +28
System.Data.Metadata.Edm.AssemblyCacheEntry.InternalLoadAssemblyFromCache(LoadingContext context) +290
System.Data.Metadata.Edm.AssemblyCacheEntry.LoadAssemblyFromCache(Assembly assembly, Boolean loadReferencedAssemblies, Dictionary`2 knownAssemblies, Dictionary`2& typesInLoading, List`1& errors) +137
System.Data.Metadata.Edm.ObjectItemCollection.LoadAssemblyFromCache(ObjectItemCollection objectItemCollection, Assembly assembly, Boolean loadReferencedAssemblies) +284
System.Data.Metadata.Edm.ObjectItemCollection.LoadAssemblyForType(Type type) +33
System.Data.Metadata.Edm.MetadataWorkspace.LoadAssemblyForType(Type type, Assembly callingAssembly) +80
System.Data.Objects.ObjectContext.CreateQuery(String queryString, ObjectParameter[] parameters) +106
FDDV.Models.DBEntities.get_user_master() +113
FDDV.Controllers.HomeController.validateUser(String userid, String password) +254
FDDV.Controllers.HomeController.LogOn(LogOnModel model, String returnUrl) +134
lambda_method(ExecutionScope , ControllerBase , Object[] ) +136
System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +17
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +178
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +24
System.Web.Mvc.<>c__DisplayClassd.<InvokeActionMethodWithFilters>b__a() +53
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +258
System.Web.Mvc.<>c__DisplayClassf.<InvokeActionMethodWithFilters>b__c() +20
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +193
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +316
System.Web.Mvc.Controller.ExecuteCore() +104
System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +36
System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +7
System.Web.Mvc.<>c__DisplayClass8.<BeginProcessRequest>b__4() +34
System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +21
System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +12
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +53
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +43
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +7
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8682542
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.4952; ASP.NET Version:2.0.50727.4955

I finally solved this problem. The main cause is the project missed some assembly references. I add the following code to the login function to find out the reflection type load exception. Once again, thanks everyone 's helpful
try{
//Do your work
}
catch (Exception ex)
{
ReflectionTypeLoadException exception = ex as ReflectionTypeLoadException;
if (exception == null)
System.IO.File.AppendAllText("C:\\TestLog.txt", "Not a ReflectionTypeLoadException ex.");
else
{
foreach (Exception loaderException in exception.LoaderExceptions)
{
System.IO.File.AppendAllText("C:\\TestLog.txt", loaderException.Message);
System.IO.File.AppendAllText("C:\\TestLog.txt", loaderException.StackTrace);
}
}
return true;
}

I faintly recall having a similar issue with MVC 3 when I upgraded a project from MVC 2 and had some version issues in my web.config.
Try enabling fusion assembly log binding and see if you can find maybe what the load is failing on.
http://www.hanselman.com/blog/BackToBasicsUsingFusionLogViewerToDebugObscureLoaderErrors.aspx
I found a script a while back that allowed me to work with fusion log better in IIS (I was having problems where it didn't run in IIS).

Related

Schema specified is not valid - error in asp.net application after upgrade Oracle database

I have an asp.net web application which uses only SQL Database on Windows SQL Server 2008. When Oracle client was upgraded (I didn't do this), something has changed. I saw that in IIS in "String Connections" appeared additional empty connection - OraAspNetConString and I'm start getting errors on these pages of my app, where should be displayed information from SQL Database.
I don't know where should I start repairing, because I'm not using Oracle database, but errors are connected with this. I don't want to change app code also, because I'm using deploying version. So maybe do you have any ideas?
There is an error below which I'm getting:
Server Error in '/Budzet' Application.
Schema specified is not valid. Errors:
Oracle.DataAccess.src.EntityFramework.Resources.EFOracleStoreSchemaDefinition.ssdl(2,2) : error 0152: No Entity Framework provider found for the ADO.NET provider with invariant name 'Oracle.DataAccess.Client'. Make sure the provider is registered in the 'entityFramework' section of the application config file. See http://go.microsoft.com/fwlink/?LinkId=260882 for more information.
Models.Model_Excel.ssdl(2,49) : error 0172: All SSDL artifacts must target the same provider. The Provider 'Oracle.DataAccess.Client' is different from 'Oracle.DataAccess.Client' that was encountered earlier.
Models.Model_Excel.ssdl(2,82) : error 0169: All SSDL artifacts must target the same provider. The ProviderManifestToken '2008' is different from '9.2' that was encountered earlier.
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.Data.Entity.Core.MetadataException: Schema specified is not valid. Errors:
Oracle.DataAccess.src.EntityFramework.Resources.EFOracleStoreSchemaDefinition.ssdl(2,2) : error 0152: No Entity Framework provider found for the ADO.NET provider with invariant name 'Oracle.DataAccess.Client'. Make sure the provider is registered in the 'entityFramework' section of the application config file. See http://go.microsoft.com/fwlink/?LinkId=260882 for more information.
Models.Model_Excel.ssdl(2,49) : error 0172: All SSDL artifacts must target the same provider. The Provider 'Oracle.DataAccess.Client' is different from 'Oracle.DataAccess.Client' that was encountered earlier.
Models.Model_Excel.ssdl(2,82) : error 0169: All SSDL artifacts must target the same provider. The ProviderManifestToken '2008' is different from '9.2' that was encountered earlier.
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:
[MetadataException: Schema specified is not valid. Errors:
Oracle.DataAccess.src.EntityFramework.Resources.EFOracleStoreSchemaDefinition.ssdl(2,2) : error 0152: No Entity Framework provider found for the ADO.NET provider with invariant name 'Oracle.DataAccess.Client'. Make sure the provider is registered in the 'entityFramework' section of the application config file. See http://go.microsoft.com/fwlink/?LinkId=260882 for more information.
Models.Model_Excel.ssdl(2,49) : error 0172: All SSDL artifacts must target the same provider. The Provider 'Oracle.DataAccess.Client' is different from 'Oracle.DataAccess.Client' that was encountered earlier.
Models.Model_Excel.ssdl(2,82) : error 0169: All SSDL artifacts must target the same provider. The ProviderManifestToken '2008' is different from '9.2' that was encountered earlier.]
System.Data.Entity.Core.Metadata.Edm.Loader.ThrowOnNonWarningErrors() +44
System.Data.Entity.Core.Metadata.Edm.Loader.LoadItems(IEnumerable`1 xmlReaders, IEnumerable`1 sourceFilePaths) +180
System.Data.Entity.Core.Metadata.Edm.Loader..ctor(IEnumerable`1 xmlReaders, IEnumerable`1 sourceFilePaths, Boolean throwOnError, IDbDependencyResolver resolver) +127
System.Data.Entity.Core.Metadata.Edm.StoreItemCollection.Init(IEnumerable`1 xmlReaders, IEnumerable`1 filePaths, Boolean throwOnError, IDbDependencyResolver resolver, DbProviderManifest& providerManifest, DbProviderFactory& providerFactory, String& providerInvariantName, String& providerManifestToken, Memoizer`2& cachedCTypeFunction) +131
System.Data.Entity.Core.Metadata.Edm.StoreItemCollection..ctor(IEnumerable`1 xmlReaders, IEnumerable`1 filePaths) +223
System.Data.Entity.Core.Metadata.Edm.MetadataCache.LoadStoreCollection(EdmItemCollection edmItemCollection, MetadataArtifactLoader loader) +88
System.Data.Entity.Core.Metadata.Edm.<>c__DisplayClass7.<GetMetadataWorkspace>b__1() +14
System.Lazy`1.CreateValue() +415
System.Lazy`1.LazyInitValue() +152
System.Lazy`1.get_Value() +75
System.Data.Entity.Core.Metadata.Edm.<>c__DisplayClass7.<GetMetadataWorkspace>b__4() +9
System.Data.Entity.Core.Metadata.Edm.MetadataWorkspace.LoadAndCheckItemCollection(Func`1 itemCollectionLoader) +16
System.Data.Entity.Core.Metadata.Edm.<>c__DisplayClass16.<.ctor>b__f() +21
System.Lazy`1.CreateValue() +415
System.Lazy`1.LazyInitValue() +152
System.Lazy`1.get_Value() +75
System.Data.Entity.Core.Metadata.Edm.MetadataWorkspace.GetItemCollection(DataSpace dataSpace, Boolean required) +92
System.Data.Entity.Core.Metadata.Edm.MetadataWorkspace.GetItemCollection(DataSpace dataSpace) +12
System.Data.Entity.Core.Objects.ObjectContext.InitializeMappingViewCacheFactory(DbContext owner) +46
System.Data.Entity.Core.Objects.ObjectContext..ctor(EntityConnection connection, Boolean isConnectionConstructor, ObjectQueryExecutionPlanFactory objectQueryExecutionPlanFactory, Translator translator, ColumnMapFactory columnMapFactory) +571
System.Data.Entity.Internal.InternalConnection.CreateObjectContextFromConnectionModel() +65
System.Data.Entity.Internal.LazyInternalConnection.CreateObjectContextFromConnectionModel() +20
System.Data.Entity.Internal.LazyInternalContext.InitializeContext() +465
System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType) +18
System.Data.Entity.Internal.Linq.InternalSet`1.Initialize() +53
System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext() +15
System.Data.Entity.Infrastructure.DbQuery`1.System.Linq.IQueryable.get_Provider() +38
System.Linq.Queryable.FirstOrDefault(IQueryable`1 source) +49
Budzet.Controllers.HomeController.Contact() +127
lambda_method(Closure , ControllerBase , Object[] ) +62
System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +14
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +182
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +27
System.Web.Mvc.Async.<>c__DisplayClass42.<BeginInvokeSynchronousActionMethod>b__41() +28
System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +10
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +50
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +49
System.Web.Mvc.Async.<>c__DisplayClass39.<BeginInvokeActionMethodWithFilters>b__33() +58
System.Web.Mvc.Async.<>c__DisplayClass4f.<InvokeActionMethodFilterAsynchronously>b__49() +225
System.Web.Mvc.Async.<>c__DisplayClass37.<BeginInvokeActionMethodWithFilters>b__36(IAsyncResult asyncResult) +10
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +50
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +49
System.Web.Mvc.Async.<>c__DisplayClass2a.<BeginInvokeAction>b__20() +24
System.Web.Mvc.Async.<>c__DisplayClass25.<BeginInvokeAction>b__22(IAsyncResult asyncResult) +99
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +50
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +44
System.Web.Mvc.<>c__DisplayClass1d.<BeginExecuteCore>b__18(IAsyncResult asyncResult) +14
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +23
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +55
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +41
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +23
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +55
System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +31
System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +10
System.Web.Mvc.<>c__DisplayClass8.<BeginProcessRequest>b__3(IAsyncResult asyncResult) +25
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +23
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +55
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +31
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9657896
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.34237

Grant ASP.NET MVC 3 website write access to ~/Content/uploads folder

I have an ASP.NET MVC 3 website that runs on the company intranet to which I want to add a page that can upload files to the server.
I am running the site on Windows Server 2012 with IIS 8.
IIS Config:
Application pool attributes:
.Net Framework v4.0
Managed Pipeline Mode: Integrated
Identity: LocalSystem
Under the site node, authentication is set as:
Windows Authentication: Enabled (Users must use their corporate Windows Accounts to log in)
All other Authentication including Anonymous Authentication set to Disabled.
Windows Permissions:
In the Content directory, I have granted all access permissions to the System, Admin and my User's account.
MVC Code:
The MVC Controller method that handles the file upload contains the following code:
[HttpPost]
public ActionResult Upload(HttpPostedFileBase file)
{
if (file != null && file.ContentLength > 0)
{
var fileName = Path.GetFileName(file.FileName);
DateTime timestamp = DateTime.Today;
var path = Path.Combine(Server.MapPath("~/Content/uploads"), fileName);
if( !Directory.Exists(path))
Directory.CreateDirectory(path);
file.SaveAs(path);
}
return RedirectToAction("Index");
}
When I try to upload a file using the above controller I get the following error:
Server Error in '/' Application.
Access to the path 'C:\Sites\ClosedBeta\Content\uploads\test.csv' is denied.
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.UnauthorizedAccessException: Access to the path 'C:\Sites\ClosedBeta\Content\uploads\test.csv' is denied.
ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6 and IIS 7, and the configured application pool identity on IIS 7.5) that is used if the application is not impersonating. If the application is impersonating via <identity impersonate="true"/>, the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.
To grant ASP.NET access to a file, right-click the file in File Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access.
Source Error:
Line 34: if( !Directory.Exists(path))
Line 35: Directory.CreateDirectory(path);
Line 36: file.SaveAs(path);
Line 37: }
Line 38:
Source File: C:\Users\****\Documents\Visual Studio 2010\Projects\Solution\Project\Controllers\UploadTestController.cs Line: 36
Stack Trace:
[UnauthorizedAccessException: Access to the path 'C:\Sites\ClosedBeta\Content\uploads\test.csv' is denied.]
System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) +10760710
System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) +1352
System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy) +60
System.IO.FileStream..ctor(String path, FileMode mode) +55
System.Web.HttpPostedFile.SaveAs(String filename) +94
System.Web.HttpPostedFileWrapper.SaveAs(String filename) +9
Project.Controllers.UploadTestController.Upload(HttpPostedFileBase file) in C:\Users\****\Documents\Visual Studio 2010\Projects\Solution\Project\Controllers\UploadTestController.cs:36
lambda_method(Closure , ControllerBase , Object[] ) +180
System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +14
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +214
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +27
System.Web.Mvc.<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12() +55
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +253
System.Web.Mvc.<>c__DisplayClass17.<InvokeActionMethodWithFilters>b__14() +21
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +191
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +324
System.Web.Mvc.Controller.ExecuteCore() +106
System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +91
System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +10
System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +34
System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +19
System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +10
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +48
System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f) +7
System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +22
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +60
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9629708
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
Any adivce would be apreciated
I think that the problem was simply that I needed to wait a bit for the permissions to take effect.
After Comming back to the same code the next day, it worked perfectly.
simply go though iis check is IISUSER and IUSR_ has permission to read and write
Generally plesk panel and cpanel add default permission to read list and write but in some cases something goes wrong and u need to setup the right permission.
So you have 2 way to achive your goal:
If you have access to iss do it by youself
or
Ask to your hosting company to setup write and read permission to this particular folder.

ASP.NET MS11-100: how can I change the limit on the maximum number of posted form values? value="10000000000" not working

I am getting this error message.
Server Error in '/' Application.
Operation is not valid due to the current state of the object.
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.InvalidOperationException: Operation is not valid due to the current state of the object.
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:
[InvalidOperationException: Operation is not valid due to the current state of the object.]
System.Web.HttpValueCollection.ThrowIfMaxHttpCollectionKeysExceeded() +2420322
System.Web.HttpValueCollection.FillFromEncodedBytes(Byte[] bytes, Encoding encoding) +58
System.Web.HttpRequest.FillInFormCollection() +159
[HttpException (0x80004005): The URL-encoded form data is not valid.]
System.Web.HttpRequest.FillInFormCollection() +217
System.Web.HttpRequest.get_Form() +104
Microsoft.Web.Infrastructure.DynamicValidationHelper.<>c__DisplayClass8.<MakeCollectionsLazy>b__2() +12
Microsoft.Web.Infrastructure.DynamicValidationHelper.<>c__DisplayClass12.<ReplaceCollection>b__e() +61
Microsoft.Web.Infrastructure.DynamicValidationHelper.<>c__DisplayClass12.<ReplaceCollection>b__11() +17
Microsoft.Web.Infrastructure.DynamicValidationHelper.DeferredCountArrayList.get_Count() +17
System.Collections.Specialized.NameObjectCollectionBase.get_Count() +15
System.Web.HttpRequest.ValidateNameValueCollection(NameValueCollection nvc, RequestValidationSource requestCollection) +23
System.Web.HttpRequest.get_Form() +150
System.Web.HttpRequestWrapper.get_Form() +11
System.Web.Mvc.HttpRequestExtensions.GetHttpMethodOverride(HttpRequestBase request) +126
System.Web.Mvc.AcceptVerbsAttribute.IsValidForRequest(ControllerContext controllerContext, MethodInfo methodInfo) +41
System.Web.Mvc.HttpGetAttribute.IsValidForRequest(ControllerContext controllerContext, MethodInfo methodInfo) +40
System.Web.Mvc.<>c__DisplayClass11.<RunSelectionFilters>b__d(ActionMethodSelectorAttribute attr) +24
System.Linq.Enumerable.All(IEnumerable`1 source, Func`2 predicate) +145
System.Web.Mvc.ActionMethodSelector.RunSelectionFilters(ControllerContext controllerContext, List`1 methodInfos) +319
System.Web.Mvc.ActionMethodSelector.FindActionMethod(ControllerContext controllerContext, String actionName) +59
System.Web.Mvc.ReflectedControllerDescriptor.FindAction(ControllerContext controllerContext, String actionName) +62
System.Web.Mvc.ControllerActionInvoker.FindAction(ControllerContext controllerContext, ControllerDescriptor controllerDescriptor, String actionName) +16
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +105
System.Web.Mvc.Controller.ExecuteCore() +116
System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +97
System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +10
System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +37
System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +21
System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +12
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +50
System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f) +7
System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +22
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +60
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8969201
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272
I have tried doing the suggested fix off
<appSettings>
<add key="aspnet:MaxHttpCollectionKeys" value="1001" />
</appSettings>
I tried putting it at some crazy number
<add key="aspnet:MaxHttpCollectionKeys" value="10000000000" />
yet it still gives me the same error (I have alot of fields but not that many). I am using asp.net mvc 3 (razor). I am using .net 4.0.
I am sending the whole form by jquery ajax(seralizeArrary) so I don't know if that has something to do with it or not.
Use a more reasonable value such as 32000, that works fine for me.
Is there a way also to limit it to which forms this is allowed on and not global as it seems to be right now?
No, I don't think that is is possible to handle this setting per form. This is because the values are parsed very eary before the routing takes place, but only after routing it would be known what "form" this belongs to.
Following are the limits:
MaxHttpCollectionKeys is an int, so it could have a max value of an integer (int.MaxValue: 2,147,483,647)
Minimum value is 1
Default value is 1000
Check on MSDN

MVC3 with Razor throws Method not found: 'System.Object System.Web.Mvc.ControllerBase.get_ViewModel()'

Fresh IIS7.5 installation on Win Server 2008 R2.
Installed MVC3 etc. via Web Platform Installer.
Made a basic MVC3 application locally. Just "new project" without anything to it.
Made an application on the IIS to host the application. AppPool set to .Net4.
When I run the application locally I get this:
Blockquote
Method not found: 'System.Object
System.Web.Mvc.ControllerBase.get_ViewModel()'.
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.MissingMethodException: Method
not found: 'System.Object
System.Web.Mvc.ControllerBase.get_ViewModel()'.
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:
[MissingMethodException: Method not
found: 'System.Object
System.Web.Mvc.ControllerBase.get_ViewModel()'.]
MinTest.Controllers.HomeController.Index()
in C:\Projects\MinTest\MinTest\Controllers\HomeController.cs:17
lambda_method(Closure , ControllerBase
, Object[] ) +79
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext
controllerContext, IDictionary2
parameters) +264
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext
controllerContext, ActionDescriptor
actionDescriptor, IDictionary2
parameters) +39
System.Web.Mvc.<>c_DisplayClass15.b_12()
+129 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter
filter, ActionExecutingContext
preContext, Func1 continuation)
+784922 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext
controllerContext, IList1 filters,
ActionDescriptor actionDescriptor,
IDictionary`2 parameters) +314
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext
controllerContext, String actionName)
+784976 System.Web.Mvc.Controller.ExecuteCore()
+159 System.Web.Mvc.ControllerBase.Execute(RequestContext
requestContext) +335
System.Web.Mvc.<>c_DisplayClassb.b_5()
+62 System.Web.Mvc.Async.<>c_DisplayClass1.b_0()
+20 System.Web.Mvc.<>c_DisplayClasse.b_d()
+54 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
+453 System.Web.HttpApplication.ExecuteStep(IExecutionStep
step, Boolean& completedSynchronously)
+371
I'm lost!
t.
I don't think you are actually loading MVC 3 in IIS. Sounds like you're getting MVC 2 instead. Double-check your MVC 3 installation on the server. Also examine the bindingRedirect in Web.Config.

NPOI dll (third party excel writer dll)....System.Security.SecurityException: That assembly does not allow partially trusted callers

I had developed portal on Asp.net mvc framework.I had hosted this site at godaddy hosting.I had a great problem on integrating third party dll i.e. NPOI (excel writer dll).It dispaly following error.
Security Exception
**Description**: *The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.*
**Exception Detail*s**:* System.Security.SecurityException: That assembly does not allow partially trusted callers.
**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:
[SecurityException: That assembly does not allow partially trusted callers.]
ETravel.Web.Modules.Travel.Controllers.Admin.ReportController.TravelTaxList() in ReportController.cs:853
lambda_method(ExecutionScope , ControllerBase , Object[] ) +39
System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +17
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +178
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +24
System.Web.Mvc.<>c__DisplayClassa.<InvokeActionMethodWithFilters>b__7() +52
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +254
System.Web.Mvc.<>c__DisplayClassc.<InvokeActionMethodWithFilters>b__9() +19
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +254
System.Web.Mvc.<>c__DisplayClassc.<InvokeActionMethodWithFilters>b__9() +19
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +254
System.Web.Mvc.<>c__DisplayClassc.<InvokeActionMethodWithFilters>b__9() +19
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +192
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +399
System.Web.Mvc.Controller.ExecuteCore() +126
System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +27
System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +7
System.Web.Mvc.MvcHandler.ProcessRequest(HttpContextBase httpContext) +151
System.Web.Mvc.MvcHandler.ProcessRequest(HttpContext httpContext) +57
System.Web.Mvc.MvcHandler.System.Web.IHttpHandler.ProcessRequest(HttpContext httpContext) +7
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +181
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75
To solve this problem i had added this code line in web.config file.
<compilation debug="true">
<assemblies>
..................... .............
<add assembly ="NPOI, Version=1.2.1.0, Culture=neutral, PublicKeyToken=0df73ec7942b34e1"/>
<add assembly="NPOI.POIFS, Version=1.2.1.0, Culture=neutral, PublicKeyToken=0df73ec7942b34e1"/>
<add assembly ="NPOI.HPSF, Version=1.2.1.0, Culture=neutral, PublicKeyToken=0df73ec7942b34e1"/>
<add assembly ="NPOI.Util, Version=1.2.1.0, Culture=neutral, PublicKeyToken=0df73ec7942b34e1"/>
</assemblies>
</compilation>
And [assembly: AllowPartiallyTrustedCallers()] to Assemblyinfo.cs.
But worn't work.what's the main problem and what is the solution???Pls help me...
No, it's NPOI that needs to allow partially trusted callers. It's probably doing something under-the-covers that won't work in a medium trust environment.
Looking at the NPOI website it looks like it was updated to run in medium trust environments towards the end of last year, but that was after the 1.2.1 release. You should try the latest version, 1.2.3 beta, to see if that update has made it in and if that will fix it for you.

Resources