Problems with ServiceStack on IIS 8.0 Arvixe server - asp.net

I am having some problems getting ServiceStack to work on my Arvixe ASP.NET server which runs on IIS 8.0.
I followed the tutorial on http://servicestack.net/ServiceStack.Hello/, creating an empty ASP.NET Web Application and issuing the command "PM> Install-Package ServiceStack.Host.AspNet" in Package Manager Console.
After doing this I could run the Web Application just fine from Visual Studio on localhost and the Todo app worked fine and I could call the /hello/{Name} url to get the correct result.
I then tried to upload the project to my Arvixe ASP.NET server which runs on IIS 8.0 and here it doesn't work. The Todo app loads but does not work with adding items, and when I try to access the /metadata or /hello/{Name} I get an HTTP Error 404.0 - Not Found like so:
I am completely new to ServiceStack so I don't know how to work around this problem. Can someone tell what I should do to get this working?
EDIT
My Web.config
<?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=169433
-->
<configuration>
<connectionStrings>
<add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<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="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>
<httpHandlers><add path="*" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*" /></httpHandlers></system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<validation validateIntegratedModeConfiguration="false" />
<handlers><add path="*" name="ServiceStack.Factory" type="ServiceStack.WebHost.Endpoints.ServiceStackHttpHandlerFactory, ServiceStack" verb="*" preCondition="integratedMode" resourceType="Unspecified" allowPathInfo="true" /></handlers></system.webServer>
</configuration>

SOLVED
I found out what the problem was: I had to manually upload the Web.config file generated by Visual Studio. Once this file was uploaded to the root at the webserver, the example worked as it should. Apparently the Web.config file is not automatically uploaded to the server when using Publish from Visual Studio 2010.

Actually the web.config is uploaded when you publish your website with Visual Studio 2010. There must be a setting where you are not letting web.config to upload.

Related

Configuration Error in IIS 7 for Virtual Directory ASP.NET website

This could be an issue with many things, but I'm trying to narrow down the source of the issue in my IIS setup or web.config configuration. That's where I need your help. I will explain my setup below. Normally I create web sites in IIS 7, and not virtual directories, but I have a bunch of shared JavaScript frameworks in my root directory (unminified right now), and I have a bunch of applications sharing those files.
My theory is that I do not have configuration for the web site itself. The path of the web site is the folder above the virtual directory path. Something tells me I need this, but I don't remember what it needs to look like.
Thoughts?
Note, this setup works just fine in Windows XP virtual directory setup. But I get this error on both Windows 7 and Windows Server 2008.
Here is the website error:
Error in text (for searching):
Server Error in '/' Application.
Configuration Error
Descriptionn: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS.
Source Error:
<compilation debug=true" targetFramework="4.0" />
Website URL:
http://localhost/app/index.aspx
Changed these 3 settings in my app pool (of the site in which the virtual directory resides in):
Disabled 'Anonymous Authentication' and Enabled 'Windows Authentication':
web.config file in virtual directory folder (sub folder of web site):
<?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=169433
-->
<configuration>
<configSections>
</configSections>
<connectionStrings>
<!-- Local Machine -->
<add name="DATABASE" connectionString="Data Source=SERVERNAME\SQLEXPRESS;Initial Catalog=DATABASE-DEV;User ID=sa;Password=xxx" providerName="System.Data.SqlClient" />
</connectionStrings>
<!--<dataConfiguration defaultDatabase="DataAccessQuickStart">
<providerMappings>
<add databaseType="Devart.Data.Oracle.EnterpriseLibrary.OracleDatabase,Devart.Data.Oracle.EnterpriseLibrary" name="OracleX" />
</providerMappings>
</dataConfiguration>-->
<!--<location path="." allowOverride="true">
</location>-->
<system.web>
<compilation debug="true" targetFramework="4.0" />
<authentication mode="Windows" />
<authorization>
<deny users = "?" />
</authorization>
<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>
<webServices>
<protocols>
<add name="HttpGet" />
<add name="HttpPost" />
</protocols>
</webServices>
<trace writeToDiagnosticsTrace="true" enabled="true" pageOutput="false" />
</system.web>
<appSettings>
</appSettings>
<!--<identity impersonate="true" />-->
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
</system.webServer>
</configuration>
You have to configure the virtual directory as 'application' in IIS

a section registered as allowDefinition='MachineToApplication' beyond application level

After adding the assebly of System.Data.Entity to my web config I got this error:
It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS.
I have deleted the obj and bin folders, I removed the line authentication="windows", tried to reopen as some has said it worked, I have checked that there is only 1 web.config within the main folder (Entity Framework - Folder for forms, model, DAL and BLL)...
What other reasons is there that this will happen? I searched everywhere and it's basically the above reasons I found....
This is my web.config if it makes a difference:
<configuration>
<connectionStrings>
<add name="ApplicationServices"
connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true"
providerName="System.Data.SqlClient" />
<add name="CStringVKB" connectionString="Data Source=.;Initial Catalog=VKB;Persist Security Info=True;User ID=websiteservice;Password=websiteservice" providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
<compilation debug="true" optimizeCompilations="true" targetFramework="4.0" >
<assemblies>
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</assemblies>
</compilation>
<!--<authentication mode="Windows">
<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="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>
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
What can I do to solve this?
Basically, the error means that there is a web.config file in one of your subfolders that has a configuration element that it should not have. Is this you root/only web config file? If not, could you please post those as well?
Also, it sounds stupid, but I would double check that you're opening the website itself in your IDE (and not mistakenly opening a parent folder) I have seen people spend a couple hours trying to debug this same error, when all along they weren't in the right directory.
Here is a good explanation on how the web.config hierarchy is set up for ASP that will help you visualize how this works: http://scottonwriting.net/sowblog/archive/2010/02/17/163375.aspx
Apparently there were two web.config files in my solution. I am using MVC4 and there was another config file under Views and i was making the change in the wrong file. Fixed there helped me.
But you can always change the default redirect/route in the global.asax file.
Chris Noreikis's answer is in fact correct. But missing an important detail. If for whatever reason you open the project/solution in a different VS version than it was originally created VS will attempt to migrate. Occasionally during this migration, VS will create a folder called "backup", or "backup_{#}". Even if you undo the pending changes this migration forces, these directories remain.
The presence of these directories are in some cases (like mine) the cause of this error. Removing these directories will eradicate the problem.
My hope is that this saves someone the countless hours I lost on this problem.

Can't create asp.net membership database aspnetdb

I can't seem to create the aspnetdb.mdf via the Web Site Administration Tool.
I am using SQL Express 2008 and Visual Studio Web Developer 2010 Express.
I get following error in the Administration Tool:
There is a problem with your selected data store. This can be caused
by an invalid server name or credentials, or by insufficient
permission. It can also be caused by the role manager feature not
being enabled. Click the button below to be redirected to a page where
you can choose a new data store.
The following message may help in diagnosing the problem: An error
occurred during the execution of the SQL file 'InstallCommon.sql'. The
SQL error number is 5170 and the SqlException message is: Cannot
create file 'C:\USERS**\DOCUMENTS\VISUAL STUDIO
2010\WEBSITES\BUGZ-B-GONE\APP_DATA\ASPNETDB_TMP.MDF' because it
already exists. Change the file path or the file name, and retry the
operation. CREATE DATABASE failed. Some file names listed could not be
created. Check related errors. Creating the
ASPNETDB_97c73957a1fb4a189ccca0449aa7d754 database...
I also get this error when I delete the mdf file or change the path.
Underneath is the web.config file:
<configuration>
<connectionStrings>
<add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient"/>
<add name="DATABASEConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\DATABASE.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Data.Linq, 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 connectionStringName="ApplicationServices" applicationName="/"
name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" />
<add applicationName="/" name="AspNetWindowsTokenRoleProvider"
type="System.Web.Security.WindowsTokenRoleProvider" />
</providers>
</roleManager>
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
Your error says that the database is already present, so first delete it and then run WSAT. If not works then delete your web.config and add a new config file to your project and then run WSAT and add the aspnetdb database.
Also you can try aspnet_regsql
Path: C:\Windows\Microsoft.NET\Framework\v4.0.30319
Run it, then you can add or remove AspNet database tables from your database.
Read more detail on MSDN

Session timeout using Membership of ASP.Net in prod, not in dev environment

When I login to my webform in my production environment ( IIS 7.5 + SQL Server 2008), my session expires after just a few couple of seconds (less than 1 minute).
But when I do the same in my dev environment (ASP.Net Development Server + SQL Server 2008) the session is persistant long enough... (several minutes).
I use the ASP.Net membership technology with Forms authentication mode and try to use Cookies.
It look like something on the server is overriding my parameters, but I don't have access to the production IIS configuration (I subscribed to a shared hosting)
Here are my web.config parmeters:
<system.web>
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</assemblies>
</compilation>
<authentication mode="Forms">
<forms loginUrl="~/Pages/Front/Login.aspx"
protection="All"
timeout="900"
path="/"
requireSSL="false"
slidingExpiration="true"
defaultUrl="~/Pages/Front"
cookieless="UseCookies"
name="MySite" />
</authentication>
<membership defaultProvider="AspNetSqlMembershipProvider">
<providers>
<clear />
<add name="AspNetSqlMembershipProvider"
type="System.Web.Security.SqlMembershipProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
connectionStringName="XXX"
enablePasswordRetrieval="false"
enablePasswordReset="true"
requiresQuestionAndAnswer="true"
applicationName="/"
requiresUniqueEmail="false"
passwordFormat="Hashed"
maxInvalidPasswordAttempts="5"
minRequiredPasswordLength="5"
minRequiredNonalphanumericCharacters="0"
passwordAttemptWindow="10"
passwordStrengthRegularExpression=""/>
</providers>
</membership>
<roleManager enabled="true"
cookieName="booble.com"
cookieProtection="All"
cookieSlidingExpiration="true"
cookieTimeout="90"
createPersistentCookie="true"
cookieRequireSSL="false">
<providers>
<clear />
<add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="XXX" applicationName="/" />
<!--<add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" />-->
</providers>
</roleManager>
<sessionState timeout="90" />
<customErrors defaultRedirect="Error.aspx" mode="On" redirectMode="ResponseRewrite" >
<error statusCode="404" redirect="Error404.aspx"/>
</customErrors>
<!-- needed because of my Provider-->
<pages enableViewStateMac="false" />
<siteMap enabled="true" defaultProvider="AspNetXmlSiteMapProvider">
<providers>
<clear />
<add siteMapFile="Web.sitemap" name="AspNetXmlSiteMapProvider"
type="System.Web.XmlSiteMapProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
securityTrimmingEnabled="true" />
</providers>
</siteMap>
</system.web>
Thanks a LOT in advance for your answers !
The problem was coming from my shared hosting provider, I contacted them in their help forum and on of their admin "changed" something on server-side, and now it works... they didn't want to tell me what they have modified.
FYI my shared hosting provider is named OVH.com, so if you have a session timeout problem (expiring every 30 sec to 1 min), even if you have configured your web.config correctly (to be sure,I even put my sessionState mode="SQLServer") , just contact them and they will do the necessary.
I'll post here if I get an explanation, thanks for your readings
Check if your session timeout is being set through code too.
<sessionState timeout="90" />
and
cookieTimeout="90"
Should have worked fine. Development servers are very forgiving about session timeouts.
Developement server doesn't represent a proper IIS 7 environment
This provides a convenient way to test your ASP.NET application
without IIS 7 - however, we recommend that you configure
Visual Studio to test your application by using the IIS 7 environment.
The reasons for this are: The ASP.NET Development Server does not
support hosting ASP.NET applications in Integrated mode, which is the
default mode of operation used by IIS 7. This may introduce
differences in application behavior.
Refer here

ASP.Net Browser Compatibility

If I use IE to connect to my ASP.Net site and let the browser sit idle for a minute or so and then try to click on a new item, link, whatever, IE appears as though it's trying to load but never does anything.
If I connect to the site using Chrome and do the same thing Chrome pulls up the next item as expected with no delay. I've tried making changes to the web.config for sessionState and httpRuntime, to the ASP and pool settings in IIS, and I can't seem to do anything that fixes the problem in IE.
Is there another setting somewhere, perhaps in Windows to fix IE as this seems to a browser dependent issue and not related to the ASP site or IIS? I'm running out of ideas and most of the users will be using IE and not Chrome so it's not really a problem I can ignore.
Here's my web.config file if it helps:
<?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>
<connectionStrings>
<add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient"/>
<add name="TaskSystemConnectionString" connectionString="Data Source=REPORTSERVER;Initial Catalog=TaskSystem;Integrated Security=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.web>
<sessionState timeout="3600"/>
<httpRuntime executionTimeout="3600" maxRequestLength="2000000"/>
<compilation debug="true" targetFramework="4.0"/>
<authentication mode="Windows" />
<customErrors mode="Off"/>
<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 controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID" validateRequest="false"/>
</system.web>
<system.webServer>
<defaultDocument>
<files>
<add value="Home.aspx"/>
</files>
</defaultDocument>
<modules runAllManagedModulesForAllRequests="true"/>
Could be something to do with database permissions. Have you tried specifying a SQL login in your connections strings? Can the account that is running IIS access these databases?
Also check your IIS settings to ensure that the authentication mode=Windows.
I have had issues with Windows authentication when i'm not using IE. For example, Chrome doesn't pass through the user identity and i have to enter my credentials each time i access the intranet.
So... after continued research and fiddling I found a Microsoft article that fixed the problem. Seems those special folks over at Microsoft decided a one minute timeout was an appropriate default... http://support.microsoft.com/kb/813827. Once I added the two necessary entries into the registry for KeepAliveTimeout and ServerInfoTimeout the problem went away.

Resources