I'm trying to configure my visual studio 2013 asp.net mvc application to use the ncache provider for session state.
So far I have added a project reference to Alachisoft.NCache.SessionStoreProvider and Alachisoft.NCache.Web
I have also followed the steps found here, including point 9 regarding web.config and now have the following system.web section in my web.config
<system.web>
<authentication mode="None" />
<compilation debug="true" targetFramework="4.5" >
<assemblies>
<add assembly="Alachisoft.NCache.SessionStoreProvider,Version=4.1.0.0,Culture=neutral,PublicKeyToken=CFF5926ED6A53769"/>
</assemblies>
</compilation>
<httpRuntime targetFramework="4.5" />
<sessionState cookieless="false" >
<providers>
<add name="NCacheSessionProvider"
type="Alachisoft.NCacheExpress.Web.SessionState.NSessionStoreProvider"
sessionAppId="NCacheTest"
cacheName="MyClusterCache"
writeExceptionsToEventLog="false"
enableLogs="false"/>
</providers>
</sessionState>
</system.web>
However when I debug my app it still appears to be using the default inproc session state as everything works ok but my cache shows a count of 0 objects.
Using the NCache api I can add items to the cache just fine which shows up in my NCache Management console statistics.
Can anyone describe how they have set this up or see anything I am missing? Thanks in advance
I solved my problem by realising I needed to add mode="Custom" and customProvider="XXXX" attributes to the sessionState tag in the web config. It worked when I added these.
My working Web config now includes
<system.web>
<authentication mode="None" />
<compilation debug="true" targetFramework="4.5" >
<assemblies>
<add assembly="Alachisoft.NCache.SessionStoreProvider,Version=4.1.0.0,Culture=neutral,PublicKeyToken=CFF5926ED6A53769"/>
</assemblies>
</compilation>
<httpRuntime targetFramework="4.5" />
<sessionState mode="Custom" customProvider="NCacheSessionProvider" cookieless="false" >
<providers>
<add name="NCacheSessionProvider"
type="Alachisoft.NCache.Web.SessionState.NSessionStoreProvider"
sessionAppId="NCacheTest"
cacheName="MyClusterCache"
writeExceptionsToEventLog="false"
enableLogs="false"/>
</providers>
</sessionState>
</system.web>
When I add to my session state I can now see 1 object added to my NCache cache.
Related
I create a project in asp .net mvc 5 with default OWIN authentication with users and roles tables. when a user logs in the default timeout is 5 minutes and after 5 minutes user logout and redirect to login page. How can I increase this time from 5 minutes to 24 hours.
I try these codes but didn't work:
ExpireTimeSpan = TimeSpan.FromHours(24),
SlidingExpiration = true
this is a part of my project's web.config file:
<system.web>
<customErrors mode="Off" />
<authentication mode="None" />
<compilation targetFramework="4.6" />
<httpRuntime targetFramework="4.6" />
</system.web>
<system.webServer>
<modules>
<remove name="FormsAuthentication" />
</modules>
</system.webServer>
I added this tag to <system.web> and the problem is solved:
<machineKey validationKey="7DB9F31CBC3B6059038DF7212AD3A01E34C64A0883E05A0987EC697E659FFC58FBE36BDA98185DA62555690CD8C286C6752D6BFAB0C3519DE777A7EFCD21984D" decryptionKey="7908EB5206AB8C410BC2117F2778C7D24EDC2537739449A272CD4DDBB1116E13" validation="SHA1" decryption="AES" />
Generate your own machine key using this website:
http://www.allkeysgenerator.com/Random/ASP-Net-MachineKey-Generator.aspx
Try adding this key to your web.config
<system.web> <sessionState mode="InProc" timeout="1440" /> </system.web>
This my web.config file:
<configuration>
<compilation debug="true" targetFramework="4.5"/>
<httpRuntime targetFramework="4.5"/>
<connectionString>
<add
name="ColMAX"
connectionString="data Source=SHANTHA;Initial Catalog=Billing_Test;Integrated Security=True"
providerName="System.Data.SqlClient"/>
</connectionString>
<system.web>
<compilation debug="true"/>
<authentication mode="Forms">
<forms
defaultUrl="~Default/.aspx"
loginUrl="~/Login.aspx"
slidingExpiration="true"
timeout="2880"></forms>
</authentication>
</system.web>
</configuration>
I can't access the login page. This is the error I get:
Detailed Error Information:
Module : IIS Web Core
Notification : Unknown
Handler :Not yet determined
Error Code :0x80070032
Config Error : The configuration section 'compilation' cannot be
read because it is missing a section declaration Config File
\?\c:\users\sudath\documents\visual studio
2013\Projects\Colombo\Colombo\web.config
I just start my project. Can anyone solve this ?
Update your Web.config as below.
<configuration>
<connectionString>
<add name="ColMAX" connectionString="data Source=SHANTHA;Initial Catalog=Billing_Test;Integrated Security=True" providerName="System.Data.SqlClient"/>
</connectionString>
<system.web>
<compilation debug="true" targetFramework="4.5"/>
<httpRuntime targetFramework="4.5"/>
<authentication mode="Forms">
<forms defaultUrl="~Default/.aspx" loginUrl="~/Login.aspx" slidingExpiration="true" timeout="2880"></forms>
</authentication>
</system.web>
</configuration>
Registering Application Pool for .Net frameWork 4.5
Navigate to
C:\Windows\Microsoft.NET\Framework\v4.0.30319
Open the command window here (Ctrl + Shift + RightClick ) -> Open command Window here.
Type the below commad in the command window.
aspnet_regiis.exe -i
Hope this will fix your peoblem.
How can I disable forms authentication? Every time I navigate to a page, the page tries to authenticate through an SQL instance on server. I have set forms authentication to none, but still no change.
http://go.microsoft.com/fwlink/?LinkId=169433 -->
<system.web>
<httpRuntime maxRequestLength="65536" executionTimeout="3600"/>
<compilation debug="true" targetFramework="4.0" />
<!--<authorization>
<allow users="*"/>
</authorization>-->
<!--<authentication mode="None">
<forms loginUrl="~/Account/Login" timeout="2880" defaultUrl="~/" />
</authentication>-->
<profile defaultProvider="DefaultProfileProvider">
<providers>
<add name="DefaultProfileProvider" type="System.Web.Providers.DefaultProfileProvider,
System.Web.Providers, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35"
connectionStringName="DefaultConnection" applicationName="/" />
Okay, so I went with leaving Forms Authentication enabled, and rather setup IIS to have access rights to an instance of SQL Express installed the server. All pages work fine now.
I am assigned in a new ASP.Net MVC 4.0 project. Traditionally, we used to add configuration values, when testing team raise new new issues (E.g. globalization, maxQueryStringLength, machineKey). For this project, I am planning to take a new route.. All the frequently used configuration values, I am planning to add upfront… I created the following config values.. What are the other most frequently used \ common config values that are needed in an ASP.Net project?
system.web
<system.web>
<!--Culture-->
<globalization culture="en-US" uiCulture="en" />
<!--Remove Custom Errors Mode in Production-->
<customErrors mode="Off"/>
<!--Impersonate-->
<identity impersonate="true"/>
<!--Session Mode and Timeout-->
<sessionState mode="InProc" timeout="60" />
<!--maxQueryStringLength-->
<httpRuntime maxQueryStringLength="6000" />
<!--machineKey-->
<machineKey/>
<!--authentication-->
<authentication mode="Windows">
</authentication>
<!--authorization-->
<authorization>
<allow users="?" />
</authorization>
</system.web>
system.webServer
<system.webServer>
<security>
<requestFiltering>
<!--maxQueryString-->
<requestLimits maxQueryString="6000" />
</requestFiltering>
<!--IIS Setting for Authentication-->
<authentication>
<anonymousAuthentication enabled="false" />
<windowsAuthentication>
<providers>
<clear />
<add value="NTLM" />
</providers>
</windowsAuthentication>
</authentication>
</security>
</system.webServer>
It is a good practice to add connection strings to web.config as well. Not sure whether you require accessing data in this project, but if you do then you need to add the following to the web.config file as well.
<connectionStrings>
<add name="myConnectionString" connectionString="server=localhost;Database=myDb;uid=myUser;password=myPass;" />
</connectionStrings>
I am deploying Asp.net Application at IIS server getting this error, But when i run this application my server its fine and give no problem .I have one html static web site in that html site folder i made tool folder, In that tool folder i deploy my asp.net application ,
Server Error in '/' Application.
Runtime Error
Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.
Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".
<!-- Web.Config Configuration File -->
<configuration>
<system.web>
<customErrors mode="Off"/>
</system.web>
</configuration>
Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's <customErrors> configuration tag to point to a custom error page URL.
<!-- Web.Config Configuration File -->
<configuration>
<system.web>
<customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/>
</system.web>
</configuration>
Here is my 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=169433
-->
<configuration>
<system.web>
<authorization>
<allow roles="administrators" />
<deny users="*" />
</authorization>
</system.web>
<connectionStrings>
<add name="ConnectionStringName" connectionString="Provider=Microsoft.ACE.OLEDB.12.0;Data Source='|DataDirectory|\mfaridalam1.accdb'; Persist Security Info=False"/>
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Web.Extensions.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/></assemblies></compilation>
<authentication mode="Forms">
<forms loginUrl="~/Account/Login.aspx" 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="true">
<providers>
<clear/>
<add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/"/>
<add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/"/>
</providers>
</roleManager>
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
<system.web>
<httpHandlers>
<add verb="*" path="AjaxFileUploadHandler.axd" type="AjaxControlToolkit.AjaxFileUploadHandler, AjaxControlToolkit" />
</httpHandlers>
</system.web>
<system.webServer>
<handlers>
<add name="AjaxFileUploadHandler" verb="*" path="AjaxFileUploadHandler.axd" type="AjaxControlToolkit.AjaxFileUploadHandler, AjaxControlToolkit" />
</handlers>
</system.webServer>
<location path="AjaxFileUploadHandler.axd">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>
</configuration>
Here is SS of error
Can you please try deleting the website from iis and restarting iis? at the same time clean your project and rebuild it. then try publishing it in the right location. Are you creating virtual directory?
This is quite a general error which does not give us details of what went wrong.
Possible checks you can do is:
1. Check web.config and make Custom Error Mode off
2. Try to host application locally
3. Check all files have been deployed on server or not?
4. View page locally on server
5. Add stacktrace to find exact issue.
6. Do logging on request
if you have access on server and using windows server, try to open the website in browser and if it fails then look into Event Viewer -> Windows Logs of windows to see the error.