setup blazor debugging on production server - debugging
I have a Blazor WASM asp.net core hosted project and a Windows Server VPS, There is an exception that only occurs on This server. I've tried many times to reproduce the error on my local machine with no luck. how should I debug a Blazor WASM project's (Client Code) on my production environment. I've tried publishing my asp project with debug config and using alt+shift+d but my project threw an exception
blazor.webassembly.js:1 Cannot start debugging, because the application was not compiled with debugging enabled.
What is the procedure to enable alt + shift + d on production server?
BTW this is the exception I'm getting and there is no sign of it in my Local system or staging server:
icrosoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
Unhandled exception rendering component: ConstructorParamIncompleteBinding, Void .ctor(System.Collections.Generic.List`1[System.Tuple`2[PShop.Presentation.Shared.Filters.FilterType,System.String]], PShop.Presentation.Shared.PaginatedResultDto`1[PShop.Presentation.Shared.Products.ProductCardDto]), System.Tuple`2[System.Collections.Generic.List`1[System.Tuple`2[PShop.Presentation.Shared.Filters.FilterType,System.String]],PShop.Presentation.Shared.PaginatedResultDto`1[PShop.Presentation.Shared.Products.ProductCardDto]]
System.InvalidOperationException: ConstructorParamIncompleteBinding, Void .ctor(System.Collections.Generic.List`1[System.Tuple`2[PShop.Presentation.Shared.Filters.FilterType,System.String]], PShop.Presentation.Shared.PaginatedResultDto`1[PShop.Presentation.Shared.Products.ProductCardDto]), System.Tuple`2[System.Collections.Generic.List`1[System.Tuple`2[PShop.Presentation.Shared.Filters.FilterType,System.String]],PShop.Presentation.Shared.PaginatedResultDto`1[PShop.Presentation.Shared.Products.ProductCardDto]]
at System.Text.Json.ThrowHelper.ThrowInvalidOperationException_ConstructorParameterIncompleteBinding(ConstructorInfo , Type )
at System.Text.Json.Serialization.Converters.ObjectWithParameterizedConstructorConverter`1[[System.Tuple`2[[System.Collections.Generic.List`1[[System.Tuple`2[[PShop.Presentation.Shared.Filters.FilterType, PShop.Presentation.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.String, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[PShop.Presentation.Shared.PaginatedResultDto`1[[PShop.Presentation.Shared.Products.ProductCardDto, PShop.Presentation.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], PShop.Presentation.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].OnTryRead(Utf8JsonReader& , Type , JsonSerializerOptions , ReadStack& , Tuple`2& )
at System.Text.Json.Serialization.JsonConverter`1[[System.Tuple`2[[System.Collections.Generic.List`1[[System.Tuple`2[[PShop.Presentation.Shared.Filters.FilterType, PShop.Presentation.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.String, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[PShop.Presentation.Shared.PaginatedResultDto`1[[PShop.Presentation.Shared.Products.ProductCardDto, PShop.Presentation.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], PShop.Presentation.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].TryRead(Utf8JsonReader& , Type , JsonSerializerOptions , ReadStack& , Tuple`2& )
at System.Text.Json.Serialization.JsonConverter`1[[System.Tuple`2[[System.Collections.Generic.List`1[[System.Tuple`2[[PShop.Presentation.Shared.Filters.FilterType, PShop.Presentation.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.String, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[PShop.Presentation.Shared.PaginatedResultDto`1[[PShop.Presentation.Shared.Products.ProductCardDto, PShop.Presentation.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], PShop.Presentation.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ReadCore(Utf8JsonReader& , JsonSerializerOptions , ReadStack& )
at System.Text.Json.JsonSerializer.ReadCore[Tuple`2](JsonConverter , Utf8JsonReader& , JsonSerializerOptions , ReadStack& )
at System.Text.Json.JsonSerializer.ReadCore[Tuple`2](JsonReaderState& , Boolean , ReadOnlySpan`1 , JsonSerializerOptions , ReadStack& , JsonConverter )
at System.Text.Json.JsonSerializer.<ReadAsync>d__20`1[[System.Tuple`2[[System.Collections.Generic.List`1[[System.Tuple`2[[PShop.Presentation.Shared.Filters.FilterType, PShop.Presentation.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.String, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[PShop.Presentation.Shared.PaginatedResultDto`1[[PShop.Presentation.Shared.Products.ProductCardDto, PShop.Presentation.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], PShop.Presentation.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].MoveNext()
at System.Net.Http.Json.HttpContentJsonExtensions.<ReadFromJsonAsyncCore>d__3`1[[System.Tuple`2[[System.Collections.Generic.List`1[[System.Tuple`2[[PShop.Presentation.Shared.Filters.FilterType, PShop.Presentation.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.String, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[PShop.Presentation.Shared.PaginatedResultDto`1[[PShop.Presentation.Shared.Products.ProductCardDto, PShop.Presentation.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], PShop.Presentation.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].MoveNext()
at PShop.Presentation.Blazor.Shop.Services.HttpDecorator.BaseHttpDecorator.<HandleResponse>d__13`1[[System.Tuple`2[[System.Collections.Generic.List`1[[System.Tuple`2[[PShop.Presentation.Shared.Filters.FilterType, PShop.Presentation.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.String, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[PShop.Presentation.Shared.PaginatedResultDto`1[[PShop.Presentation.Shared.Products.ProductCardDto, PShop.Presentation.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], PShop.Presentation.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].MoveNext()
at PShop.Presentation.Blazor.Shop.Services.HttpDecorator.BaseHttpDecorator.<Post>d__4`2[[System.Tuple`2[[System.Collections.Generic.List`1[[System.Tuple`2[[PShop.Presentation.Shared.Filters.FilterType, PShop.Presentation.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.String, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[PShop.Presentation.Shared.PaginatedResultDto`1[[PShop.Presentation.Shared.Products.ProductCardDto, PShop.Presentation.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], PShop.Presentation.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Collections.Generic.List`1[[System.Tuple`2[[PShop.Presentation.Shared.Filters.FilterType, PShop.Presentation.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.String, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].MoveNext()
at PShop.Presentation.Blazor.Shop.Services.Filter.FilterService.Filter(ICollection`1 filterRequests, Int32 pageIndex, Int32 pageSize, String search, FilterSort sort)
at PShop.Presentation.Blazor.Shop.Store.FilterUseCases.FilterEffects.OnFetchFilter(FetchFilters action, IDispatcher dispatcher)
at Fluxor.Blazor.Web.StoreInitializer.OnAfterRender(Boolean firstRender)
at Microsoft.AspNetCore.Components.ComponentBase.Microsoft.AspNetCore.Components.IHandleAfterRender.OnAfterRenderAsync()
at Microsoft.AspNetCore.Components.Rendering.ComponentState.NotifyRenderCompletedAsync()
Related
The type or namespace name 'Linq' does not exist in the namespace 'System' (are you missing an assembly reference?) error in cshtml file
I know that my question was already put, but none of the solutions provided couldn't help me. I have a project similar with this one. In line 1 of Viewer.cshtml file from Views->Home folder I'm getting the error The type or namespace name 'Linq' does not exist in the namespace 'System' (are you missing an assembly reference?). Viewer.cshtml code: <style> .custom-image-item { background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4IiB2aWV3Qm94PSIwIDAgMjYgMjYiIHN0eWxlPSJlbmFibGUtYmFja2dyb3VuZDpuZXcgMCAwIDI2IDI2OyIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+PHN0eWxlIHR5cGU9InRleHQvY3NzIj4uc3Qwe2ZpbGw6IzNEM0QzRDt9PC9zdHlsZT48Zz48cGF0aCBjbGFzcz0ic3QwIiBkPSJNMjUsN2MwLTAuMi0wLjEtMC42LTAuMy0wLjdDMjQuNiw2LjEsMjQuNCw2LDI0LjIsNkgxNnY1LjdsMS45LDEuN0wyNSw3eiIvPjxwYXRoIGNsYXNzPSJzdDAiIGQ9Ik0xLDIybDE0LDNWMUwxLDRWMjJ6IE04LDEwYzEuNywwLDMsMS44LDMsNGMwLDIuMi0xLjMsNC0zLDRzLTMtMS44LTMtNEM1LDExLjgsNi4zLDEwLDgsMTB6Ii8+PHBhdGggY2xhc3M9InN0MCIgZD0iTTE4LDE1bC0yLTJsMCw4bDguMiwwYzAuMiwwLDAuNC0wLjEsMC42LTAuM2MwLjItMC4yLDAuMi0wLjQsMC4yLTAuNkwyNSw5TDE4LDE1TDE4LDE1eiIvPjxlbGxpcHNlIGNsYXNzPSJzdDAiIGN4PSI4IiBjeT0iMTQiIHJ4PSIyIiByeT0iMyIvPjwvZz48L3N2Zz4NCg==); background-repeat: no-repeat; } </style> <script> function CustomizeMenuActions(s, e) { var itemDisabled = ko.observable(true); s.Init.AddHandler(function (s) { var exportDisabled = s.GetReportPreview().exportDisabled; exportDisabled.subscribe(function (newValue) { itemDisabled(newValue); }); itemDisabled(exportDisabled()); }); var sendViaEmailItem = { id: 'someCustomId', imageClassName: 'custom-image-item', text: 'Send via Email', visible: true, disabled: itemDisabled, clickAction: function () { s.PerformCustomDocumentOperation('some#email.com'); } }; e.Actions.push(sendViaEmailItem); } </script> #Html.DevExpress().WebDocumentViewer(settings => { settings.Name = "WebDocumentViewer1"; settings.ClientSideEvents.CustomizeMenuActions = "CustomizeMenuActions"; }).Bind(new XtraReport1()).GetHtml() I have added in Views\Web.config this <compilation debug="false"> <assemblies> <add assembly="System.Core, Version=4.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/> <add assembly="System.Xml.Linq, Version=4.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/> <add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/> <add assembly="System.Web.Extensions.Design, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> <add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/> </assemblies> </compilation> but with no success. I also have added System.Data.Linq, System.Xml.linq references but it didn't solve the error. What should I do to get rid of this error? Thanks in advance!
Why the .svclog file is not getting created even it is enabled on SvcConfigEditor.exe (App.config file) for windows application?
I have Enabled the Tracing and message logging and so the app.config file too but still the below svclog files not getting created on the path: app_messages.svclog app_tracelog.svclog After making these changes the app.config is like below: ```<configuration> <configSections> <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <section name="xx.xx.MyAppLogSettings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/> </sectionGroup> <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <section name="xx.xx.MyAppLogSettings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false"/> </sectionGroup> </configSections> <system.diagnostics> <sources> <source propagateActivity="true" name="System.ServiceModel" switchValue="Warning,ActivityTracing"> <listeners> <add type="System.Diagnostics.DefaultTraceListener" name="Default"> <filter type="" /> </add> <add name="ServiceModelTraceListener"> <filter type="" /> </add> </listeners> </source> <source name="System.ServiceModel.MessageLogging" switchValue="Warning,ActivityTracing"> <listeners> <add type="System.Diagnostics.DefaultTraceListener" name="Default"> <filter type="" /> </add> <add name="ServiceModelMessageLoggingListener"> <filter type="" /> </add> </listeners> </source> </sources> <sharedListeners> <add initializeData="C:\Projects\MyAppLog\app_tracelog.svclog" type="System.Diagnostics.XmlWriterTraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" name="ServiceModelTraceListener" traceOutputOptions="Timestamp"> <filter type="" /> </add> <add initializeData="C:\Projects\MyAppLog\app_messages.svclog" type="System.Diagnostics.XmlWriterTraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" name="ServiceModelMessageLoggingListener" traceOutputOptions="Timestamp"> <filter type="" /> </add> </sharedListeners> <trace autoflush="false" /> </system.diagnostics> <applicationSettings> <xx.xx.MyAppLogSettings> <setting name="LogLevel" serializeAs="String"> <value>0</value> </setting> </xx.xx.MyAppLogSettings> </applicationSettings> <startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/></startup><userSettings> <xx.xx.MyAppLogSettings> <setting name="ErrorFile" serializeAs="String"> <value>MyAppErrors.xml</value> </setting> </xx.xx.MyAppLogSettings> </userSettings> <system.serviceModel> <diagnostics performanceCounters="Default"> <messageLogging logEntireMessage="true" logKnownPii="true" logMalformedMessages="true" logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true" /> <endToEndTracing propagateActivity="true" activityTracing="true" messageFlowTracing="true" /> </diagnostics> </system.serviceModel> </configuration>``` What is missing to create the Tracelog file(.svclog) at mentioned path?
Compiler Error Message: CS0103: The name 'ViewBag' does not exist in the current context
I have changed service providers, and since then as soon as i goto www.greptech.co.za i get the above error. The service provider is using .NET 4.0 and does have the latest MVC3 installed and up to date. What else can be the issue ? I have googled this, and i have done the above checks. The service provider doesnt know what else is wrong. I havent changed my Web.config file, for it was working with my old service provider. Site has been down for a long time now. Please can anyone assist Here is my web.config file : <?xml version="1.0" encoding="UTF-8"?> <!-- For more information on how to configure your ASP.NET application, please visit http://go.microsoft.com/fwlink/?LinkId=152368 --> <configuration> <connectionStrings> <add name="MySqlServer" connectionString="Datasource=431.186.904.538;Port=3306;Database=grep;uid=user;pwd='XXXX';Allow User Variables=true;check parameters=false;logging=true" providerName="MySql.Data.MySqlClient" /> </connectionStrings> <system.net> <mailSettings> <smtp deliveryMethod="Network" from="support#greptech.co.za"> <network host="mail.greptech.co.za" userName="support#greptech.co.za" password="XXXX" port="25" /> </smtp> </mailSettings> </system.net> <appSettings> <add key="ENV" value="PROD"/> <add key="webpages:Version" value="1.0.0.0" /> <add key="ClientValidationEnabled" value="true" /> <add key="UnobtrusiveJavaScriptEnabled" value="true" /> </appSettings> <system.web> <!-- <customErrors mode="On"/> --> <trace enabled="true" pageOutput="false" requestLimit="40" localOnly="false" /> <compilation debug="true" targetFramework="4.0"> <assemblies> <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> <add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> <add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> <add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> </assemblies> </compilation> <authentication mode="Forms"> <forms loginUrl="~/Account/LogOn" timeout="2880" /> </authentication> <pages> <namespaces> <add namespace="System.Web.Helpers" /> <add namespace="System.Web.Mvc" /> <add namespace="System.Web.Mvc.Ajax" /> <add namespace="System.Web.Mvc.Html" /> <add namespace="System.Web.Routing" /> <add namespace="System.Web.WebPages" /> </namespaces> </pages> <customErrors mode="Off"/> </system.web> <system.webServer> <validation validateIntegratedModeConfiguration="false" /> <modules runAllManagedModulesForAllRequests="true" /> <directoryBrowse enabled="true" /> <defaultDocument> <files> <clear /> <add value="Default.htm" /> <add value="Default.asp" /> <add value="index.htm" /> <add value="index.html" /> <add value="iisstart.htm" /> <add value="default.aspx" /> <add value="index.php" /> </files> </defaultDocument> </system.webServer> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" /> <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="3.0.0.0" /> </dependentAssembly> </assemblyBinding> </runtime> </configuration> Ok, thanks for the reply .. Here is the ~/Views/Web.config <?xml version="1.0"?> <configuration> <configSections> <sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"> <section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" /> <section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" /> </sectionGroup> </configSections> <system.net > <mailSettings> <smtp deliveryMethod="Network" from="support#greptech.co.za"> <network host="mail.greptech.co.za" userName="support#greptech.co.za" password="XXXX" port="25" /> </smtp> </mailSettings> </system.net> <system.web.webPages.razor> <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> <pages pageBaseType="System.Web.Mvc.WebViewPage"> <namespaces> <add namespace="System.Web.Mvc" /> <add namespace="System.Web.Mvc.Ajax" /> <add namespace="System.Web.Mvc.Html" /> <add namespace="System.Web.Routing" /> </namespaces> </pages> </system.web.webPages.razor> <appSettings> <add key="webpages:Enabled" value="false" /> </appSettings> <system.web> <httpHandlers> <add path="*" verb="*" type="System.Web.HttpNotFoundHandler"/> </httpHandlers> <!-- Enabling request validation in view pages would cause validation to occur after the input has already been processed by the controller. By default MVC performs request validation before a controller processes the input. To change this behavior apply the ValidateInputAttribute to a controller or action. --> <pages validateRequest="false" pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"> <controls> <add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" namespace="System.Web.Mvc" tagPrefix="mvc" /> </controls> </pages> </system.web> <system.webServer> <validation validateIntegratedModeConfiguration="false" /> <handlers> <remove name="BlockViewHandler"/> <add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" /> </handlers> </system.webServer> </configuration> I ended up going back to original Service Provider
I think I might have an idea what's going on looking at the debug output - this part doesn't look right: Line 12: namespace ASP { Line 13: using System; Line 14: using System.Collections.Generic; Line 15: using System.IO; Line 16: using System.Linq; Line 17: using System.Net; Line 18: using System.Web; Line 19: using System.Web.Helpers; Line 20: using System.Web.Security; Line 21: using System.Web.UI; Line 22: using System.Web.WebPages; Line 23: using System.Web.WebPages.Html; Line 24: using WebMatrix.Data; Line 25: using WebMatrix.WebData; Line 26: Line 27: Line 28: public class _Page_index_cshtml : System.Web.WebPages.WebPage { First your page inherits WebPages.WebPage - how did that happen? Then above.. notice the lack of System.Web.Mvc ? That's the reason you also get errors for missing 'BeginForm' and 'Partial' methods, because they are all part of the System.Web.Mvc namespace. Here's how a fresh MVC 3 project output looks for me: Line 12: namespace ASP { Line 13: using System; Line 14: using System.Collections.Generic; Line 15: using System.IO; Line 16: using System.Linq; Line 17: using System.Net; Line 18: using System.Web; Line 19: using System.Web.Helpers; Line 20: using System.Web.Security; Line 21: using System.Web.UI; Line 22: using System.Web.WebPages; Line 23: using System.Web.Mvc; Line 24: using System.Web.Mvc.Ajax; Line 25: using System.Web.Mvc.Html; Line 26: using System.Web.Routing; Line 27: Line 28: Line 29: public class _Page_Views_Home_Index_cshtml : System.Web.Mvc.WebViewPage<dynamic> { The config you listed above is perfectly fine. However the config in /Views is what affects the generation of views and my best guess is there's something wrong there. This is the bit that I noticed makes or breaks the view output (namespaces here are directly reflected in the generated code, similar to Problem recognizing html helpers in asp.net mvc 3 razor ): <system.web.webPages.razor> <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> <pages pageBaseType="System.Web.Mvc.WebViewPage"> <namespaces> <add namespace="System.Web.Mvc" /> <add namespace="System.Web.Mvc.Ajax" /> <add namespace="System.Web.Mvc.Html" /> <add namespace="System.Web.Routing" /> </namespaces> </pages> </system.web.webPages.razor> At this point it seems like a good idea if you can also add the ~/Views/Web.config in case this is not the issue.
Ended up going back to original Service Provider
Razor view Type does not inherit from 'System.Web.WebPages.WebPage'
I have a problem with configuring asp.net mvc application: [HttpException (0x80004005): Type 'ASP._Page_Currency_Index_cshtml' does not inherit from 'System.Web.WebPages.WebPage'.] System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp) +11454171 System.Web.WebPages.BuildManagerWrapper.CreateInstanceOfType(String virtualPath) +347 System.Web.WebPages.VirtualPathFactoryManager.CreateInstanceOfType(String virtualPath) +239 System.Web.WebPages.WebPageHttpHandler.CreateFromVirtualPath(String virtualPath, IVirtualPathFactory virtualPathFactory) +57 System.Web.WebPages.WebPageRoute.DoPostResolveRequestCache(HttpContextBase context) +407 System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +80 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +270 Steps that I want to do: Move controllers with its views into separate library and put dll into bin folder. Create virtual file provider and virtual file to get data from assembly: public override Stream Open() { var resourceName = this.path; var asmName = this.assembly.GetName().Name; var manifestName = asmName + ".Views" + resourceName.Trim('~').Replace("/", "."); var resourceStream = this.assembly.GetManifestResourceStream(manifestName); return resourceStream; } Add this lines into web.config: <configSections> <sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"> <section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" /> <section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" /> </sectionGroup> </configSections> <system.web.webPages.razor> <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> <pages pageBaseType="System.Web.Mvc.WebViewPage"> <namespaces> <add namespace="System.Web.Helpers" /> <add namespace="System.Web.Mvc" /> <add namespace="System.Web.Mvc.Ajax" /> <add namespace="System.Web.Mvc.Html" /> <add namespace="System.Web.Routing" /> <add namespace="System.Web.WebPages" /> </namespaces> </pages> </system.web.webPages.razor> When user access this controller's page it is compiled correctly into the following class: public class _Page_Currency_Index_cshtml : System.Web.Mvc.WebViewPage<GridModel<CurrencyModel>> { And after that it fails with this error (and as I can see - he is right, Type 'ASP._Page_Currency_Index_cshtml' does not inherit from 'System.Web.WebPages.WebPage'.) What should I do to let HttpApplication know that this page should be managed as System.Web.Mvc.WebViewPage instead of System.Web.WebPages.WebPage? I have tried to move Views/Web.Config into bin folder, but it does not help.
Try adding this to the AppSettings in Web.Config: <add key="webpages:Enabled" value="false" />
Clients need to delete cookies most of the times in MVC
I am having my mvc project that is working fine on my local machine. However, once posted on the server, the users can`t access the login the secong time they are trying to access the website. They have to delete the cookies. Why is that so? How can I correct that? Global.asax.cs FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(Request.cookies[FormsAuthentication.FormsCookieName].Value); args.user = new MyProject.Web.UI.Classes.UserPrincipal(GetUserFromCache(ticket.Name)) SourceFile: c:\Myproject\Code\MvcUI\Global.asax.cs public void FormsAuthentication_OnAuthenticate(object sender, FormsAuthenticationEventArgs args) { if (FormsAuthentication.CookiesSupported) { if (null != Request.Cookies[FormsAuthentication.FormsCookieName]) { FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(Request.Cookies[FormsAuthentication.FormsCookieName].Value); args.User = new MyProject.Web.UI.Classes.UserPrincipal(GetUserFromCache(ticket.Name)); } } else throw new HttpException("Cookieless Forms Authentication is not supported for this application."); } public void WindowsAuthentication_OnAuthenticate(object sender, WindowsAuthenticationEventArgs args) { string username = args.Identity.Name.Substring(args.Identity.Name.IndexOf("\\") + 1); Myproject.API.User user = GetUserFromCache(username); if (null == user) throw new HttpException("User could not be found."); args.User = new MyProject.Web.UI.Classes.UserPrincipal(user); } AccountController [HttpPost] public bool LogOn(string userName, string password, string returnUrl, bool rememberMe = false) { MyProject.API.User user = MyProject.API.User.Load(userName); string errorMessage = "Your user name and/or password is incorrect."; if (null != user && user.IsValidPassword(password)) { user.LastLoginDate = DateTime.Now; user.Save(); FormsAuthentication.SetAuthCookie(userName, rememberMe); return true; } else throw new Exception(errorMessage); } web.config <?xml version="1.0"?> <!-- For more information on how to configure your ASP.NET application, please visit http://go.microsoft.com/fwlink/?LinkId=152368 --> <configuration> <configSections> <section name="nhibernate" type="System.Configuration.NameValueSectionHandler, System, Version=1.0.5000.0,Culture=neutral, PublicKeyToken=b77a5c561934e089"/> <sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"> <section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" /> <section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" /> </sectionGroup> </configSections> <system.web.webPages.razor> <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> <pages pageBaseType="System.Web.Mvc.WebViewPage"> <namespaces> <add namespace="System.Web.Mvc" /> <add namespace="System.Web.Mvc.Ajax" /> <add namespace="System.Web.Mvc.Html" /> <add namespace="System.Web.Routing" /> <add namespace="MvcUI.HtmlHelpers" /> <add namespace="MyProject.API" /> <add namespace="MvcUI.Models" /> </namespaces> </pages> </system.web.webPages.razor> <connectionStrings> <add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient" /> </connectionStrings> <appSettings> <add key="ClientValidationEnabled" value="true"/> <add key="UnobtrusiveJavaScriptEnabled" value="true"/> </appSettings> <system.web> <compilation debug="true" targetFramework="4.0"> <assemblies> <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> <add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> <add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> <add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> <add assembly="Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" /> <add assembly="Microsoft.ReportViewer.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" /> <add assembly="Microsoft.Build.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" /> <add assembly="System.Management, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" /> </assemblies> <buildProviders> <add extension=".rdlc" type="Microsoft.Reporting.RdlBuildProvider, Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> </buildProviders> </compilation> <authentication mode="Forms"> <forms loginUrl="~/Account/LogOn" timeout="2880" /> </authentication> <membership> <providers> <clear/> <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" /> </providers> </membership> <profile> <providers> <clear/> <add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/" /> </providers> </profile> <roleManager enabled="false"> <providers> <clear/> <add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/" /> <add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" /> </providers> </roleManager> <pages> <namespaces> <add namespace="System.Web.Helpers" /> <add namespace="System.Web.Mvc" /> <add namespace="System.Web.Mvc.Ajax" /> <add namespace="System.Web.Mvc.Html" /> <add namespace="System.Web.Routing" /> <add namespace="System.Web.WebPages"/> </namespaces> </pages> <httpHandlers> <add path="Reserved.ReportViewerWebControl.axd" verb="*" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" validate="false" /> </httpHandlers> </system.web> <nhibernate> <add key="hibernate.connection.provider" value="NHibernate.Connection.DriverConnectionProvider"/> <add key="hibernate.dialect" value="NHibernate.Dialect.MsSql2000Dialect"/> <add key="hibernate.connection.driver_class" value="NHibernate.Driver.SqlClientDriver"/> <add key="hibernate.connection.connection_string" value="Server=.\SQLEXPRESS;Database=myDatabase;User=me;Pwd=password;"/> <add key="hibernate.show_sql" value="false"/> </nhibernate> <system.webServer> <validation validateIntegratedModeConfiguration="false"/> <modules runAllManagedModulesForAllRequests="true"/> <handlers> <add name="ReportViewerWebControlHandler" preCondition="integratedMode" verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> </handlers> </system.webServer> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" /> <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="3.0.0.0" /> </dependentAssembly> </assemblyBinding> </runtime> </configuration> account Model public interface IFormsAuthenticationService { void SignIn(string userName, bool createPersistentCookie); void SignOut(); } public class FormsAuthenticationService : IFormsAuthenticationService { public void SignIn(string userName, bool createPersistentCookie) { if (String.IsNullOrEmpty(userName)) throw new ArgumentException("Value cannot be null or empty.", "userName"); FormsAuthentication.SetAuthCookie(userName, createPersistentCookie); } public void SignOut() { FormsAuthentication.SignOut(); } } The error message points to the Gloabal.asax.cs file and shown above. Error message: I have also included a machine key generated but it has not solved the problem,
Based on your feedback, the reason you are experiencing that error may be due to the fact you are using an auto-generated machineKey for your application (also possibly in multiple machines/app pools or even in one app pool that recycles too frequently). Please make sure to check this one out.
Have you applied this patch? I see you don't have ticketCompatibilityMode set as .net 4 has changed the way encryption works. <forms loginUrl="/Login.aspx" timeout="2880" ticketCompatibilityMode="Framework20" domain="domain.com"/> Check that you have the same machineKeys on both systems. Make sure you also apply that patch. Because the patch modifies the encryption/signing behavior of certain features in ASP.NET, it is important that you apply it to all machines in a web-farm. If you have a mix-match of patched/un-patched systems you’ll have forms-authentication, webresource.axd, and scriptresource.axd requests succeed/fail depending on which server they hit in the farm (since the encryption used would be different across them).
I assume your users are redirected to somewhere upon reaching the login page if the request is authenticated and thus they can't access the login page after the first successful login. If this is the case, you may want to force your users to sign out upon reaching the login page, on the first load of the page. For example (Razor syntax, C#): #if (!IsPost && Request.IsAuthenticated) { FormsAuthentication.SignOut(); }
On the GET (not post) of LogOn action method. Check if user is authenticated and log out if so. if (System.Web.HttpContext.Current.User.Identity.IsAuthenticated) { FormsAuthentication.SignOut(); }
Thanks to all of you for having tried to reply to the question. Indeed they were all helpful. I solved the problem myself by adding a machinekey to the wenconfig, as well as a form name had to be there. without te form name, even the machine key was not useful