I'm struggling with creating an ASP web page with SSO like in this tutorial https://learn.microsoft.com/en-us/aspnet/identity/overview/getting-started/developing-aspnet-apps-with-windows-azure-active-directory but first I got redirected to localhost after deploying the aplication, so I searched and found the solution in ASP.Net redirecting to local host after authentication. But now when I autenticate on the web page I've created I get the next error
[ArgumentException: Format of the initialization string does not conform to specification starting at index 152.]
System.Data.Common.DbConnectionOptions.GetKeyValuePair(String connectionString, Int32 currentPosition, StringBuilder buffer, Boolean useOdbcRules, String& keyname, String& keyvalue) +5778570
System.Data.Common.DbConnectionOptions.ParseInternal(Hashtable parsetable, String connectionString, Boolean buildChain, Hashtable synonyms, Boolean firstKey) +124
System.Data.Common.DbConnectionOptions..ctor(String connectionString, Hashtable synonyms, Boolean useOdbcRules) +95
System.Data.SqlClient.SqlConnectionString..ctor(String connectionString) +59
System.Data.SqlClient.SqlConnectionFactory.CreateConnectionOptions(String connectionString, DbConnectionOptions previous) +27
System.Data.ProviderBase.DbConnectionFactory.GetConnectionPoolGroup(DbConnectionPoolKey key, DbConnectionPoolGroupOptions poolOptions, DbConnectionOptions& userConnectionOptions) +167
System.Data.SqlClient.SqlConnection.ConnectionString_Set(DbConnectionPoolKey key) +61
System.Data.SqlClient.SqlConnection.set_ConnectionString(String value) +87
System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher.<SetConnectionString>b__18(DbConnection t, DbConnectionPropertyInterceptionContext`1 c) +12
System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch(TTarget target, Action`2 operation, TInterceptionContext interceptionContext, Action`3 executing, Action`3 executed) +72
System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher.SetConnectionString(DbConnection connection, DbConnectionPropertyInterceptionContext`1 interceptionContext) +360
System.Data.Entity.Internal.LazyInternalConnection.InitializeFromConnectionStringSetting(ConnectionStringSettings appConfigConnection) +269
System.Data.Entity.Internal.LazyInternalConnection.TryInitializeFromAppConfig(String name, AppConfig config) +32
System.Data.Entity.Internal.LazyInternalConnection.Initialize() +127
System.Data.Entity.Internal.LazyInternalConnection.get_ProviderName() +13
System.Data.Entity.Internal.LazyInternalContext.get_ProviderName() +11
System.Data.Entity.Internal.DefaultModelCacheKeyFactory.Create(DbContext context) +92
System.Data.Entity.Internal.LazyInternalContext.InitializeContext() +515
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, Expression`1 predicate) +83
pruebamvc.Models.ADALTokenCache..ctor(String signedInUserId) +380
pruebamvc.Startup.<ConfigureAuth>b__7_0(AuthorizationCodeReceivedNotification context) +111
Microsoft.Owin.Security.OpenIdConnect.<AuthenticateCoreAsync>d__1a.MoveNext() +4931
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +26
Microsoft.Owin.Security.OpenIdConnect.<AuthenticateCoreAsync>d__1a.MoveNext() +6453
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +92
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58
Microsoft.Owin.Security.Infrastructure.<BaseInitializeAsync>d__0.MoveNext() +571
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +92
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58
Microsoft.Owin.Security.Infrastructure.<Invoke>d__0.MoveNext() +255
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +92
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58
Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.<RunApp>d__5.MoveNext() +182
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +92
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58
Microsoft.Owin.Security.Infrastructure.<Invoke>d__0.MoveNext() +638
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +92
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58
Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.<RunApp>d__5.MoveNext() +182
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +92
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58
Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.<DoFinalWork>d__2.MoveNext() +180
Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.StageAsyncResult.End(IAsyncResult ar) +69
Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContext.EndFinalWork(IAsyncResult ar) +64
System.Web.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +380
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
I've searched if anybody else has got the same error, but not success. I have tried to update nuget packages because it looks like a parsing error with the tokem, but in Startup.Auth.cs sais that authenticationcontext has AcquireTokenByAuthorizationCode deprecated so I tried to replace old code
AuthorizationCodeReceived = (context) =>
{
var code = context.Code;
ClientCredential credential = new ClientCredential(clientId, appKey);
string signedInUserID = context.AuthenticationTicket.Identity.FindFirst(ClaimTypes.NameIdentifier).Value;
AuthenticationContext authContext = new AuthenticationContext(Authority, new ADALTokenCache(signedInUserID));
AuthenticationResult result = authContext.AcquireTokenByAuthorizationCode(
code, new Uri(HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Path)), credential, graphResourceId);
return Task.FromResult(0);
}
with:
AuthorizationCodeReceived = async (context) =>
{
var code = context.Code;
ClientCredential credential = new ClientCredential(clientId, appKey);
string signedInUserID = context.AuthenticationTicket.Identity.FindFirst(ClaimTypes.NameIdentifier).Value;
AuthenticationContext authContext = new AuthenticationContext(Authority, new ADALTokenCache(signedInUserID));
AuthenticationResult result = await authContext.AcquireTokenByAuthorizationCodeAsync(
code, new Uri(HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Path)), credential, graphResourceId);
return ;
}
But still etting errors. Do you have any idea?
but first I got redirected to localhost after deploying the apllication
You could change the redirect url both in web.config and azure ad application , please follow below steps :
After deploy , you will get the published app url :https://webapplicationname.azurewebsites.net/ , cope the url and modify the web config :
<add key="ida:PostLogoutRedirectUri" value="https://webapplicationname.azurewebsites.net/" />
In azure portal ,click Azure AD blade, click "App registrations" button , find the app you registered . You could find the app by app id(client id) , that could be find in web config:
<add key="ida:ClientId" value="ae7afda3-b24b-42a7-bb14-8d7a08227f66" />
select the app , click "Reply URLs" button , add the published app url(this demo i used webapplication420170330110754 as my app name ,change that to your own app name ) ,click save button:
Now you need to re-publish the app to make the new web.config available .
Edit :
For this error ,please firstly confirm whether you have set the correct connect string . You could find the connect string of azure sql :
Click the connect string you will get that :
Related
I am trying to connect to Google Youtube API.
The last thing I changed is : adding the line new FileDataStore(folder). The code works well on localhost but triggers the following error on the server:
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.ComponentModel.Win32Exception: Access is denied
Here is my code:
public async Task<List<string>> GetSubscriptionsRequest(string id)
{
ClientSecrets secrets = new ClientSecrets() // tutorial : https://developers.google.com/identity/sign-in/web/devconsole-project
{
ClientId = "780499768563-j5dcgafhl5rg6ivh452iihcqe57gjvut.apps.googleusercontent.com",
ClientSecret = "--"
};
string userid = id ?? "user";
System.Diagnostics.Debug.WriteLine("userid " + userid);
var folder = System.Web.HttpContext.Current.Server.MapPath("/App_Data/MyGoogleStorage");
var credentialMethod2 = await GoogleWebAuthorizationBroker.AuthorizeAsync(
secrets,
// This OAuth 2.0 access scope allows an application to upload files to the
// authenticated user's YouTube channel, but doesn't allow other types of access.
new[]
{
YouTubeService.Scope.YoutubeUpload, YouTubeService.Scope.Youtube, YouTubeService.Scope.YoutubeForceSsl
,YouTubeService.Scope.YoutubeReadonly
},
userid, // if I can change this from "user" I get triggered to http://localhost:57464/authorize/?code=4/QUj58_0CI1abkj3fJptZQpw-AxCWUw5eYOLwg9edaqk# to accept Youtube permission for the Google user
CancellationToken.None,
new FileDataStore(folder)
//new FileDataStore(this.GetType().ToString()) // CRITICAL
);
var youtubeService = new YouTubeService(new BaseClientService.Initializer()
{
HttpClientInitializer = credentialMethod2,
ApplicationName = Assembly.GetExecutingAssembly().GetName().Name // will give the name of this .net project
});
var subscriptionsListRequest = youtubeService.Subscriptions.List("snippet");
subscriptionsListRequest.MaxResults = 50;
subscriptionsListRequest.Mine = true;
var subscriptionsListResponse = await subscriptionsListRequest.ExecuteAsync();
List<string> lstSubscriptionId = new List<string>();
foreach (var channel in subscriptionsListResponse.Items)
{
//System.Diagnostics.Debug.WriteLine(channel.Snippet.Title); // The Young Turks
//System.Diagnostics.Debug.WriteLine(channel.Snippet.ResourceId.ChannelId);
lstSubscriptionId.Add(channel.Snippet.ResourceId.ChannelId);
}
return lstSubscriptionId;
}
Here is the stack trace:
Stack Trace:
[Win32Exception (0x80004005): Access is denied]
System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo) +756
System.Diagnostics.Process.Start() +131
System.Diagnostics.Process.Start(ProcessStartInfo startInfo) +49
Google.Apis.Auth.OAuth2.<ReceiveCodeAsync>d__6.MoveNext() +280
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +92
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58
Google.Apis.Auth.OAuth2.<AuthorizeAsync>d__8.MoveNext() +540
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +92
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58
Google.Apis.Auth.OAuth2.<AuthorizeAsync>d__4.MoveNext() +395
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +92
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58
Google.Apis.Auth.OAuth2.<AuthorizeAsync>d__1.MoveNext() +268
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +92
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58
Scraper_v1.Infrastructure.<GetSubscriptionsRequest>d__15.MoveNext() +576
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +92
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58
Scraper_v1.Controllers.<Mysubscriptions>d__19.MoveNext() +312
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +92
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58
lambda_method(Closure , Task ) +33
System.Threading.Tasks.TaskHelpersExtensions.ThrowIfFaulted(Task task) +35
System.Web.Mvc.Async.TaskAsyncActionDescriptor.EndExecute(IAsyncResult asyncResult) +67
System.Web.Mvc.Async.<>c__DisplayClass3f.<BeginInvokeAsynchronousActionMethod>b__3e(IAsyncResult asyncResult) +16
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +58
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +49
System.Web.Mvc.Async.<>c__DisplayClass39.<BeginInvokeActionMethodWithFilters>b__33() +57
System.Web.Mvc.Async.<>c__DisplayClass4f.<InvokeActionMethodFilterAsynchronously>b__49() +223
System.Web.Mvc.Async.<>c__DisplayClass37.<BeginInvokeActionMethodWithFilters>b__36(IAsyncResult asyncResult) +15
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +58
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) +102
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +58
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +44
System.Web.Mvc.<>c__DisplayClass1d.<BeginExecuteCore>b__18(IAsyncResult asyncResult) +15
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +16
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +58
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +54
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +16
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +58
System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +44
System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +12
System.Web.Mvc.<>c__DisplayClass8.<BeginProcessRequest>b__3(IAsyncResult asyncResult) +25
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +16
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +58
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +44
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +11
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9744373
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
Thanks
I'm trying to deploy a website to Azure Web Apps. IDE: Visual Studio 2015/U3.
Site: ASP.NET MVC 4 website. I try to deploy the site to Azure Web App through VS using Publish.
Error in browser:
Server Error in '/' Application.
The operation failed because an index or statistics with name 'IX_OwnerId' already exists on table 'dbo.Auctions'.
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.SqlClient.SqlException: The operation failed because an index or statistics with name 'IX_OwnerId'
already exists on table 'dbo.Auctions'.
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:
[SqlException (0x80131904): The operation failed because an index or statistics with name 'IX_OwnerId' already exists on table 'dbo.Auctions'.]
System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) +2442634
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) +5766568
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) +285
System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) +4162
System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async, Int32 timeout, Boolean asyncWrite) +948
System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry) +286
System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +286
System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.<NonQuery>b__0(DbCommand t, DbCommandInterceptionContext`1 c) +10
System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch(TTarget target, Func`3 operation, TInterceptionContext interceptionContext, Action`3 executing, Action`3 executed) +72
System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.NonQuery(DbCommand command, DbCommandInterceptionContext interceptionContext) +356
System.Data.Entity.Internal.InterceptableDbCommand.ExecuteNonQuery() +103
System.Data.Entity.Migrations.DbMigrator.ExecuteSql(MigrationStatement migrationStatement, DbConnection connection, DbTransaction transaction, DbInterceptionContext interceptionContext) +109
System.Data.Entity.Migrations.DbMigrator.ExecuteStatementsInternal(IEnumerable`1 migrationStatements, DbConnection connection, DbTransaction transaction, DbInterceptionContext interceptionContext) +83
System.Data.Entity.Migrations.DbMigrator.ExecuteStatementsWithinTransaction(IEnumerable`1 migrationStatements, DbTransaction transaction, DbInterceptionContext interceptionContext) +65
System.Data.Entity.Migrations.DbMigrator.ExecuteStatementsWithinNewTransaction(IEnumerable`1 migrationStatements, DbConnection connection, DbInterceptionContext interceptionContext) +155
System.Data.Entity.Migrations.DbMigrator.ExecuteStatementsInternal(IEnumerable`1 migrationStatements, DbConnection connection, DbInterceptionContext interceptionContext) +346
System.Data.Entity.Migrations.DbMigrator.ExecuteStatementsInternal(IEnumerable`1 migrationStatements, DbConnection connection) +509
System.Data.Entity.Migrations.<>c__DisplayClass30.<ExecuteStatements>b__2e() +19
System.Data.Entity.SqlServer.<>c__DisplayClass1.<Execute>b__0() +10
System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute(Func`1 operation) +189
System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute(Action operation) +78
System.Data.Entity.Migrations.DbMigrator.ExecuteStatements(IEnumerable`1 migrationStatements, DbTransaction existingTransaction) +194
System.Data.Entity.Migrations.DbMigrator.ExecuteStatements(IEnumerable`1 migrationStatements) +7
System.Data.Entity.Migrations.DbMigrator.ExecuteOperations(String migrationId, VersionedModel targetModel, IEnumerable`1 operations, IEnumerable`1 systemOperations, Boolean downgrading, Boolean auto) +828
System.Data.Entity.Migrations.DbMigrator.AutoMigrate(String migrationId, VersionedModel sourceModel, VersionedModel targetModel, Boolean downgrading) +559
System.Data.Entity.Migrations.DbMigrator.Upgrade(IEnumerable`1 pendingMigrations, String targetMigrationId, String lastMigrationId) +403
System.Data.Entity.Migrations.DbMigrator.UpdateInternal(String targetMigration) +445
System.Data.Entity.Migrations.<>c__DisplayClassc.<Update>b__b() +13
System.Data.Entity.Migrations.DbMigrator.EnsureDatabaseExists(Action mustSucceedToKeepDatabase) +422
System.Data.Entity.Migrations.DbMigrator.Update(String targetMigration) +78
System.Data.Entity.MigrateDatabaseToLatestVersion`2.InitializeDatabase(TContext context) +108
System.Data.Entity.Internal.<>c__DisplayClassf`1.<CreateInitializationAction>b__e() +76
System.Data.Entity.Internal.InternalContext.PerformInitializationAction(Action action) +60
System.Data.Entity.Internal.InternalContext.PerformDatabaseInitialization() +357
System.Data.Entity.Internal.LazyInternalContext.<InitializeDatabase>b__4(InternalContext c) +7
System.Data.Entity.Internal.RetryAction`1.PerformAction(TInput input) +110
System.Data.Entity.Internal.LazyInternalContext.InitializeDatabaseAction(Action`1 action) +198
System.Data.Entity.Internal.LazyInternalContext.InitializeDatabase() +73
System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType) +28
System.Data.Entity.Internal.Linq.InternalSet`1.Initialize() +53
System.Data.Entity.Internal.Linq.InternalSet`1.GetEnumerator() +15
System.Data.Entity.Infrastructure.DbQuery`1.System.Collections.Generic.IEnumerable<TResult>.GetEnumerator() +53
System.Linq.Enumerable.ToDictionary(IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer) +146
System.Linq.Enumerable.ToDictionary(IEnumerable`1 source, Func`2 keySelector) +89
OnlineAuction.Controllers.HomeController.Index(Int32 CategoryId, String SearchKeyword) in C:\Users\Chico\Desktop\DIPLOMA PROJECT\DIPLOMA PROJECT\Проект\задав вопрос о оунерАди\delete — копия\OnlineDonors\Controllers\HomeController.cs:26
lambda_method(Closure , ControllerBase , Object[] ) +146
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) +32
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) +34
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) +27
System.Web.Mvc.<>c__DisplayClass1d.<BeginExecuteCore>b__18(IAsyncResult asyncResult) +14
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +16
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +50
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +36
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +16
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +50
System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +26
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) +16
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +50
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +28
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9765121
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
I looked at this post:
Unhandled Exception after Upgrading to Entity Framework 4.3.1
I tried to remove duplicates on my Auctions table.
This is my Auctions and Users tables creation in Up() method of InitialCreate class:
public partial class InitialCreate : DbMigration
{
public override void Up()
{
CreateTable(
"dbo.Auctions",
c => new
{
Id = c.Long(nullable: false, identity: true),
Title = c.String(nullable: false, maxLength: 160),
Description = c.String(nullable: false),
CurrentPrice = c.Double(nullable: false),
StartTime = c.DateTime(nullable: false),
EndTime = c.DateTime(nullable: false),
OwnerId = c.Int(nullable: false),
WinningBidId = c.Int(),
CategoryId = c.Int(nullable: false),
})
.PrimaryKey(t => t.Id)
.ForeignKey("dbo.Users", t => t.OwnerId)
.ForeignKey("dbo.Bids", t => t.WinningBidId)
.ForeignKey("dbo.Categories", t => t.CategoryId)
.Index(t => t.OwnerId)
.Index(t => t.WinningBidId)
.Index(t => t.CategoryId);
}
}
At first I removed this line:
.ForeignKey("dbo.Users", t => t.OwnerId)
And redeployed the site. Still the same error.
Then I removed .Index(t => t.OwnerId) from Auctions table creation.
The same error occurs.
Additional info:
In Application_Start() method of Global.asax I have this line:
System.Data.Entity.Database.SetInitializer(new System.Data.Entity.MigrateDatabaseToLatestVersion<AuctionDataContext, Configuration>());
In <configSections> of Web.config:
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
My initializations are in Configuration class:
public class Configuration : DbMigrationsConfiguration<OnlineAuction.Models.Entities.AuctionDataContext>
{
public Configuration()
{
AutomaticMigrationsEnabled = true;
}
protected override void Seed(AuctionDataContext context)
{
***All my initializations go here
}
}
Question: How to fix it?
As far as I know, the ForeignKeyIndexConvention Code First convention could cause indexes to be created for the columns of any foreign key in the model. You could try to remove this convention on DbContext.OnModelCreating Method.
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
//your code
//remove ForeignKeyIndexConvention
modelBuilder.Conventions.Remove<ForeignKeyIndexConvention>();
}
I am getting the value from text field but can not find the reason of not getting saved in the variable.
var user = new ApplicationUser() { UserName = model.Email ,Email = model.Email};
user is null despite Email contains the value. I have found it through debugging.
{
Line 81: var user = new ApplicationUser() { UserName = model.Email ,Email = model.Email};
Line 82: var result = await UserManager.CreateAsync(user, model.Password);
Line 83: if (result.Succeeded)
Line 84: {
Line 82 is the error.
Below is the code.
var user = new ApplicationUser() { UserName = model.Email ,Email = model.Email};
var result = await UserManager.CreateAsync(user, model.Password);
if (result.Succeeded)
{
var db = new ApplicationDbContext();
var checkingAccount = new CheckingAccount
{
FirstName = model.FirstName,
LastName = model.LastName,
AccountNumber = "111014005",
Balance = 0,
ApplicationUserId = user.Id
};
db.CheckingAccounts.Add(checkingAccount);
db.SaveChanges();
Stack Trace:
[Win32Exception (0x80004005): The system cannot find the file
specified]
[SqlException (0x80131904): A network-related or instance-specific
error occurred while establishing a connection to SQL Server. The
server was not found or was not accessible. Verify that the instance
name is correct and that SQL Server is configured to allow remote
connections. (provider: SQL Network Interfaces, error: 52 - Unable to
locate a Local Database Runtime installation. Verify that SQL Server
Express is properly installed and that the Local Database Runtime
feature is enabled.)]
System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection
owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean
allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions
userOptions, DbConnectionInternal& connection) +414
System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection
owningObject, TaskCompletionSource1 retry, DbConnectionOptions
userOptions, DbConnectionInternal& connection) +78
System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection
owningConnection, TaskCompletionSource1 retry, DbConnectionOptions
userOptions, DbConnectionInternal oldConnection, DbConnectionInternal&
connection) +196
System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection
outerConnection, DbConnectionFactory connectionFactory,
TaskCompletionSource1 retry, DbConnectionOptions userOptions) +146
System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection
outerConnection, DbConnectionFactory connectionFactory,
TaskCompletionSource1 retry, DbConnectionOptions userOptions) +16
System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource1
retry) +94
System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource1
retry) +110 System.Data.SqlClient.SqlConnection.Open() +96
System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher.b__36(DbConnection
t, DbConnectionInterceptionContext c) +10
System.Data.Entity.Infrastructure.Interception.InternalDispatcher1.Dispatch(TTarget
target, Action2 operation, TInterceptionContext interceptionContext,
Action3 executing, Action3 executed) +72
System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher.Open(DbConnection
connection, DbInterceptionContext interceptionContext) +360
System.Data.Entity.SqlServer.<>c__DisplayClass33.b__32()
+426 System.Data.Entity.SqlServer.<>c__DisplayClass1.b__0() +10
System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute(Func1
operation) +189
System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute(Action
operation) +78
System.Data.Entity.SqlServer.SqlProviderServices.UsingConnection(DbConnection
sqlConnection, Action1 act) +175
System.Data.Entity.SqlServer.SqlProviderServices.UsingMasterConnection(DbConnection
sqlConnection, Action1 act) +557
System.Data.Entity.SqlServer.SqlProviderServices.CreateDatabaseFromScript(Nullable1
commandTimeout, DbConnection sqlConnection, String
createDatabaseScript) +86
System.Data.Entity.SqlServer.SqlProviderServices.DbCreateDatabase(DbConnection
connection, Nullable1 commandTimeout, StoreItemCollection
storeItemCollection) +164
System.Data.Entity.Core.Common.DbProviderServices.CreateDatabase(DbConnection
connection, Nullable1 commandTimeout, StoreItemCollection
storeItemCollection) +76
System.Data.Entity.Core.Objects.ObjectContext.CreateDatabase() +134
System.Data.Entity.Migrations.Utilities.DatabaseCreator.Create(DbConnection
connection) +119
System.Data.Entity.Migrations.DbMigrator.EnsureDatabaseExists(Action
mustSucceedToKeepDatabase) +142
System.Data.Entity.Migrations.DbMigrator.Update(String
targetMigration) +78
System.Data.Entity.Internal.DatabaseCreator.CreateDatabase(InternalContext
internalContext, Func3 createMigrator, ObjectContext objectContext)
+89 System.Data.Entity.Internal.InternalContext.CreateDatabase(ObjectContext
objectContext, DatabaseExistenceState existenceState) +116
System.Data.Entity.Database.Create(DatabaseExistenceState
existenceState) +218
System.Data.Entity.CreateDatabaseIfNotExists1.InitializeDatabase(TContext
context) +149
System.Data.Entity.Internal.<>c__DisplayClassf1.<CreateInitializationAction>b__e()
+76 System.Data.Entity.Internal.InternalContext.PerformInitializationAction(Action
action) +60
System.Data.Entity.Internal.InternalContext.PerformDatabaseInitialization()
+357 System.Data.Entity.Internal.LazyInternalContext.<InitializeDatabase>b__4(InternalContext
c) +7
System.Data.Entity.Internal.RetryAction1.PerformAction(TInput input)
+110 System.Data.Entity.Internal.LazyInternalContext.InitializeDatabaseAction(Action1
action) +198
System.Data.Entity.Internal.LazyInternalContext.InitializeDatabase()
+73 System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type
entityType) +28
System.Data.Entity.Internal.Linq.InternalSet1.Initialize() +53
System.Data.Entity.Internal.Linq.InternalSet1.get_InternalContext()
+15 System.Data.Entity.Infrastructure.DbQuery1.System.Linq.IQueryable.get_Provider()
+38 System.Data.Entity.QueryableExtensions.FirstOrDefaultAsync(IQueryable1
source, Expression1 predicate, CancellationToken cancellationToken)
+138 System.Data.Entity.QueryableExtensions.FirstOrDefaultAsync(IQueryable1
source, Expression1 predicate) +133
Microsoft.AspNet.Identity.EntityFramework.d__6c.MoveNext()
+486 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) +93
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) +52 Microsoft.AspNet.Identity.CultureAwaiter1.GetResult()
+59 Microsoft.AspNet.Identity.<ValidateUserName>d__4.MoveNext() +592 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) +93
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) +52 Microsoft.AspNet.Identity.<ValidateAsync>d__0.MoveNext()
+283 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) +93
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) +52 Microsoft.AspNet.Identity.<CreateAsync>d__0.MoveNext()
+582 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) +93
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) +52 Microsoft.AspNet.Identity.<CreateAsync>d__d.MoveNext()
+531 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) +93
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) +52 System.Runtime.CompilerServices.TaskAwaiter1.GetResult()
+24 AutomatedTellerMachine.Controllers.d__9.MoveNext() in e:\Passion\Work\AutomatedTellerMachine\AutomatedTellerMachine\Controllers\AccountController.cs:82
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) +93
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) +52
System.Web.Mvc.Async.TaskAsyncActionDescriptor.EndExecute(IAsyncResult
asyncResult) +84
System.Web.Mvc.Async.<>c__DisplayClass37.b__36(IAsyncResult
asyncResult) +17
System.Web.Mvc.Async.WrappedAsyncResult1.CallEndDelegate(IAsyncResult
asyncResult) +10
System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +49
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult
asyncResult) +32
System.Web.Mvc.Async.AsyncInvocationWithFilters.b__3d()
+50 System.Web.Mvc.Async.<>c__DisplayClass46.b__3f()
+225 System.Web.Mvc.Async.<>c__DisplayClass33.b__32(IAsyncResult asyncResult) +10
System.Web.Mvc.Async.WrappedAsyncResult1.CallEndDelegate(IAsyncResult
asyncResult) +10
System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +49
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult
asyncResult) +34
System.Web.Mvc.Async.<>c__DisplayClass2b.b__1c()
+26 System.Web.Mvc.Async.<>c__DisplayClass21.b__1e(IAsyncResult
asyncResult) +100
System.Web.Mvc.Async.WrappedAsyncResult1.CallEndDelegate(IAsyncResult
asyncResult) +10
System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +49
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult
asyncResult) +27
System.Web.Mvc.Controller.b__1d(IAsyncResult
asyncResult, ExecuteCoreState innerState) +13
System.Web.Mvc.Async.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult
asyncResult) +36
System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +54
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +39
System.Web.Mvc.Controller.b__15(IAsyncResult
asyncResult, Controller controller) +12
System.Web.Mvc.Async.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult
asyncResult) +28
System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +54
System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +29
System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult
asyncResult) +10
System.Web.Mvc.MvcHandler.b__5(IAsyncResult
asyncResult, ProcessRequestState innerState) +21
System.Web.Mvc.Async.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult
asyncResult) +36
System.Web.Mvc.Async.WrappedAsyncResultBase1.End() +54
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()
+9514812 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
The stack trace shows that your application cannot connect to your database:
SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 52 - Unable to locate a Local Database Runtime installation. Verify that SQL Server Express is properly installed and that the Local Database Runtime feature is enabled.)
Note the highlighted section: This indicated that you don't have LocalDb installed. Either install it or change your connection string to point to a database that does exist.
System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) +357
In my application I have a page that displays a list of records and with every record there is a link to click for more details of that record. It goes to the other controller.
Let me tell a sequence. From 'ToDoListSelect' controller it goes to 'ToDoList' and on clicking the link from ToDoList it goes to 'Info' controller. Everything works fine on my development machine with same database as on the server.
Now, I put the package on server and there it works okay if the records on the page are less than 500 or so. If there are more records then from ToDoList it does not go to Info but throws exception and I see it's going to ToDoListSelect which is weird. I do not know where to start looking for the problem. Any suggestions? Any details needed just let me know.
Here are the routes in my application:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute( "Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
}
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
RegisterGlobalFilters(GlobalFilters.Filters);
RegisterRoutes(RouteTable.Routes);
}
The error thrown is:
Server Error in '/' Application.
The operation is invalid because of 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 this error, view and determine where the error originated in the code.
Exception Details: System.InvalidOperationException: Operation is not valid due to the current state of the object.
Source Error:
During execution of the current web request An unhandled exception was generated. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
[InvalidOperationException: Der Vorgang ist aufgrund des aktuellen Zustands des Objekts ungültig.]
System.Web.HttpRequest.FillInFormCollection() +11485999
System.Web.HttpRequest.get_Form() +157
Microsoft.Web.Infrastructure.DynamicValidationHelper.<>c__DisplayClass12.<ReplaceCollection>b__e() +63
Microsoft.Web.Infrastructure.DynamicValidationHelper.<>c__DisplayClass12.<ReplaceCollection>b__11() +20
Microsoft.Web.Infrastructure.DynamicValidationHelper.DeferredCountArrayList.get_Count() +20
System.Web.HttpRequest.ValidateNameValueCollection(NameValueCollection nvc, RequestValidationSource requestCollection) +34
System.Web.HttpRequest.get_Form() +212
System.Web.Mvc.FormValueProvider..ctor(ControllerContext controllerContext, IUnvalidatedRequestValues unvalidatedValues) +55
System.Web.Mvc.FormValueProviderFactory.GetValueProvider(ControllerContext controllerContext) +61
System.Web.Mvc.<>c__DisplayClassc.<GetValueProvider>b__7(ValueProviderFactory factory) +28
System.Linq.WhereSelectEnumerableIterator`2.MoveNext() +238
System.Linq.WhereSelectEnumerableIterator`2.MoveNext() +148
System.Collections.Generic.List`1..ctor(IEnumerable`1 collection) +472
System.Linq.Enumerable.ToList(IEnumerable`1 source) +80
System.Web.Mvc.ValueProviderFactoryCollection.GetValueProvider(ControllerContext controllerContext) +347
System.Web.Mvc.ControllerBase.get_ValueProvider() +46
System.Web.Mvc.ControllerActionInvoker.GetParameterValue(ControllerContext controllerContext, ParameterDescriptor parameterDescriptor) +80
System.Web.Mvc.ControllerActionInvoker.GetParameterValues(ControllerContext controllerContext, ActionDescriptor actionDescriptor) +153
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +691
System.Web.Mvc.Controller.ExecuteCore() +162
System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +305
System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +62
System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +20
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +469
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +375
Figured it out! Thanks Mr. Google!
http://geekswithblogs.net/renso/archive/2012/01/19/operation-is-not-valid-due-to-the-current-state-of.aspx
Put the change in web.config and it works fine.
I had updated my app from MVC 1 to MVC 2. After that some pages throws PathTooLongException:
[PathTooLongException: The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.]
System.IO.Path.SafeSetStackPointerValue(Char* buffer, Int32 index, Char value) +7493057
System.IO.Path.NormalizePathFast(String path, Boolean fullCheck) +387
System.IO.Path.NormalizePath(String path, Boolean fullCheck) +36
System.IO.Path.GetFullPathInternal(String path) +21
System.Security.Util.StringExpressionSet.CanonicalizePath(String path, Boolean needFullPath) +73
System.Security.Util.StringExpressionSet.CreateListFromExpressions(String[] str, Boolean needFullPath) +278
System.Security.Permissions.FileIOPermission.AddPathList(FileIOPermissionAccess access, AccessControlActions control, String[] pathListOrig, Boolean checkForDuplicates, Boolean needFullPath, Boolean copyPathList) +87
System.Security.Permissions.FileIOPermission..ctor(FileIOPermissionAccess access, String path) +65
System.Web.InternalSecurityPermissions.PathDiscovery(String path) +29
System.Web.HttpRequest.MapPath(VirtualPath virtualPath, VirtualPath baseVirtualDir, Boolean allowCrossAppMapping) +146
System.Web.HttpRequest.MapPath(VirtualPath virtualPath) +37
System.Web.HttpServerUtility.Execute(IHttpHandler handler, TextWriter writer, Boolean preserveForm, Boolean setPreviousPage) +43
System.Web.HttpServerUtility.Execute(IHttpHandler handler, TextWriter writer, Boolean preserveForm) +28
System.Web.HttpServerUtilityWrapper.Execute(IHttpHandler handler, TextWriter writer, Boolean preserveForm) +22
System.Web.Mvc.ViewPage.RenderView(ViewContext viewContext) +284
System.Web.Mvc.WebFormView.RenderViewPage(ViewContext context, ViewPage page) +82
System.Web.Mvc.WebFormView.Render(ViewContext viewContext, TextWriter writer) +85
System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +267
System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) +10
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +320
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) +30
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +7
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8678910
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
I know the issue with 260-character-url-lenght in ASP.NET, but my app works fine before update to ASP.NET MVC 2.0!
This problem occurs not only locally but on a remote hosting too
I compare RenderView method implementations.
MVC 1:
public virtual void RenderView(ViewContext viewContext) {
ViewContext = viewContext;
InitHelpers();
// Tracing requires Page IDs to be unique.
ID = Guid.NewGuid().ToString();
ProcessRequest(HttpContext.Current);
}
MVC 2:
public virtual void RenderView(ViewContext viewContext) {
ViewContext = viewContext;
InitHelpers();
bool needServerExecute = false;
SwitchWriter switchWriter = viewContext.HttpContext.Response.Output as SwitchWriter;
if (switchWriter == null) {
switchWriter = new SwitchWriter();
needServerExecute = true;
}
using (switchWriter.Scope(viewContext.Writer)) {
if (needServerExecute) {
// It's safe to reset the _nextId within a Server.Execute() since it pushes a new TraceContext onto
// the stack, so there won't be an ID conflict.
int originalNextId = _nextId;
try {
_nextId = 0;
viewContext.HttpContext.Server.Execute(HttpHandlerUtil.WrapForServerExecute(this), switchWriter, true /* preserveForm */);
}
finally {
// Restore the original _nextId in case this isn't actually the outermost view, since resetting
// the _nextId may now cause trace ID conflicts in the outer view.
_nextId = originalNextId;
}
}
else {
ProcessRequest(HttpContext.Current);
}
}
}
This is more of an ASP.NET 4.0 default limit rather than ASP.NET MVC 1.0 to 2.0 migration issue. Try increasing this limit in web.config:
<httpRuntime maxUrlLength="1000" relaxedUrlToFileSystemMapping="true" />
Problem is solved. It was caused by Spring.NET. WebApplicationContext works correctly with ASP.NET MVC 1.0. But couple WebApplicationContext + ASP.NET MVC 2.0 causes PathTooLongException. Now i just switch to XmlApplicationContext and all pages renders without errors.