Session management in Azure application - azure

link textI developed a simple cloud application with default webrole and implemented the following steps.
1.Created new cloud service application with one default Webrole1
2. Extracted “ AspProviders.dll” and added as reference to the current Webrole1.
3. Added to new web form to the existing web role and named it as Login.aspx
4. The design page of Login.aspx is edit as below
5. Below line is added in Page Load event of Default.aspx
Response.Write("Hello, " + Server.HtmlEncode(User.Identity.Name));
6. Edited web.config with the following changes
.................
<!--Below lines are added to avoid error occured related to Insecure end points connection -->
.................
.................
................
................
.................
<sessionState mode="Custom" customProvider="TableStorageSessionStateProvider">
<providers>
<clear />
<add name="TableStorageSessionStateProvider"
type="Microsoft.Samples.ServiceHosting.AspProviders.TableStorageSessionStateProvider"
applicationName="SampleCloudApp"/>
</providers>
</sessionState>
<!--End-->
.................
...............``
..............
7. Executed the application in local DevFabric
But I am getting run time error like "Value Cannot be null" and the stack trace is like the following
Let me know the solution for this
Thanks.

Not sure how you pasted in the changes you made to web.config or the stack trace, but I don't see them - maybe try again.
Also have you read this post that mentions the same error?
Note also that AspProviders is just sample code - I found it took a bit of tweaking to get it to work the last time I tried to use it and I seem to remember there was a problem with the role provider. Not sure if that was fixed or if you're using the June 2010 Azure SDK (hint: you should be.)

Related

No Code First Migrations When Deploying Via Visual Studio 2013

I've written an API with no azure connection currently. I am now ready to publish this to Azure. In doing so, I assumed, as was the case with many other deployments, there would be an option for code first migrations. The website already exists, so when I log in I select my website in the drop down, but the screen I get looks like the below where the code-first migrations checkbox should be:
How do I correct this so that I can deploy with code-first migrations?
I found the solution to this issue. If this happens, then your publish profile is set to update the database schema, but not to allow code first migrations. I can't speak to why Visual Studio sometimes does this, but to fix it, you'll need to alter the xml file representing that profile. They can be found under the 'Publish Profiles' folder. Most likely, your <PublishDatabaseSettings> element will have an <Object Type="Dbfx...etc."> and possibly and <UpdateFrom> element. Get rid of those and replace the settings with the below.
<PublishDatabaseSettings>
<Objects xmlns="">
<ObjectGroup Name="Namespace.Models.YourDBClass" Order="1" Enabled="True">
<Destination Path="your-connection-string-goes-here" />
<Object Type="DbCodeFirst">
<Source Path="DBMigration" DbContext="Namespace.Models.YourDBClass, AssamblyName" MigrationConfiguration="Namespace.Migrations.Configuration, Assambly" Origin="Convention" />
</Object>
</ObjectGroup>
</Objects>
</PublishDatabaseSettings>
Now clean and rebuild for good measure and you should be ready to go. Do note, if you do not delete the other pre-generated elements in the PublishDatabaseSettings element the schema will update on publish and you will likely have an error on your first attempt to hit your API and the migrations occur. In my case, and in most, it will be an 'X already exists' error, as the migrations are attempting to create tables that were already created with the schema update.
I was able to figure out the issue and correct it with the help of this article: http://www.dominicstpierre.com/2012/11/enable-code-first-migrations-check-box.html

Configuring the Runtime Policy in Glimpse MVC4 , EF6

I used the runtimepolicies element in my web.Config file to configure the runtime policy.
But when run the application give a run-time exception like below.
Parser Error Message: Unrecognized element 'runtimepolicies'.
Please give me your support to configure the runtime policy in the Glimpse correctly.
The easiest way to do this, is by going to [yoursite]/glimpse.axd and use the configuration tool on the right side.
You can then check and uncheck wanted or unwanted runtime policies, tabs,... and it will show you the config changes you need to apply.
Updated answer to show correct configuration based on comment below
<glimpse defaultRuntimePolicy="On" endpointBaseUri="~/Glimpse.axd">
<runtimePolicies>
<ignoredTypes>
<add type="Glimpse.AspNet.Policy.LocalPolicy, Glimpse.AspNet"></add>
</ignoredTypes>
</runtimePolicies>
</glimpse>

Does dot(.) in project name cause "No owin.Enviroment" error?

After almost two hours struggling with No owin.Environment error, I am now wondering if the dot . in the project name causes the error.
My project name is XXX.Web.
In my Startup.cs, there is attribute
[assembly: OwinStartup(typeof(WVCCIS.Web.Startup))]
In the Web.Config, I added
<add key="owin:AppStartup" value="XXX.Web.Startup, XXX.Web" />
<add key="owin:AutomaticAppStartup " value="false" />
It works fine in VS2013 IIS Express, even without the appSettings keys added. But I have never figured out why it failed in the production site, hosed on an IIS7.
The error message is: No owin.Environment item was found in the context.
I found in the article login crashes - no owin.Environment
Some comment says,
I can reproduce this bug with MVC5 project by changing namespace to one which contains dots. For example WebApplication1 works, Company.ABC.WebApplication1 doesn't.
If that is the case, how can I fix it for some project name that contains a dot? How come it works when debugging in VS, but failed in the production site?
Thanks for any assistance.

Blob wad-iis-logfiles is never created

I just started checking out Windows Azure and I have trouble getting any access logs from IIS for my test web role. The web role itself works fine, but I would like to see a log for accesses (both successful and failed).
As far as I can see the default configuration files for a web role contain instructions to send those logs to a blob named "wad-iis-logfiles", but that blob is never even created (it doesn't exist in my blob storage).
My diagnostics.wadcfg for the web role currently is:
<DiagnosticMonitorConfiguration configurationChangePollInterval="PT1M" overallQuotaInMB="4096" xmlns="http://schemas.microsoft.com/ServiceHosting/2010/10/DiagnosticsConfiguration">
<DiagnosticInfrastructureLogs bufferQuotaInMB="512" scheduledTransferPeriod="PT5M" />
<Directories bufferQuotaInMB="512" scheduledTransferPeriod="PT5M">
<IISLogs container="wad-iis-logfiles" />
<CrashDumps container="wad-crash-dumps" />
</Directories>
<Logs bufferQuotaInMB="512" scheduledTransferPeriod="PT5M" scheduledTransferLogLevelFilter="Information" />
<PerformanceCounters bufferQuotaInMB="512">
(... snip...)
</PerformanceCounters>
<WindowsEventLog bufferQuotaInMB="512" scheduledTransferPeriod="PT1M" scheduledTransferLogLevelFilter="Error">
<DataSource name="Application!*" />
</WindowsEventLog>
</DiagnosticMonitorConfiguration>
Question 1: is this configuration file correct?
Question 2: are there other things that need to be set before I can get the IIS log files?
With the help of the commenters I was able to solve the issue.
There are several interacting things causing the issue.
As commenter #kwill mentioned, an existing configuration blob in wad-control-container overrides any other configuration, and that configuration is not replaced during an in-place update. I was using in-place update to put my modified diagnostics.wadcfg in place, so that is the explanation why my attempts to change settings that way didn't work. Note that editing the properties of the web test role (in the "Roles" branch of the Azure Cloud services project operates by editing that same file, so that didn't work either. More information on how that wad-control-container overrides setting can be found in http://msdn.microsoft.com/en-us/library/windowsazure/dn205146.aspx .
The reason that blob already existed may have been that I had been changing some other performance measurement settings in the azure management window earlier.
I managed to "fix" the situation by editing the blob found in wad-control-container for my instance, using the tool mentioned by commenter #Gaurav Mantri - "Azure Explorer". As mentioned, without that tool you can download the blob and edit it, but never put it back properly, since the '/' characters in the blob's name get translated to '%2F', and those are not translated back on upload.
Note that the XML schema is not the same as the schema for diagnostics.wadcfg, but some similarities exist. I changed the "Directories" element toward the bottom of the blob to read:
<Directories>
<BufferQuotaInMB>512</BufferQuotaInMB>
<ScheduledTransferPeriodInMinutes>2</ScheduledTransferPeriodInMinutes>
<Subscriptions>
<DirectoryConfiguration>
<Path>C:\Resources\directory\8091b0be14e54213ac12fcbd5f9c8e1b.WebTestRole.DiagnosticStore\CrashDumps</Path>
<Container>wad-crash-dumps</Container>
<DirectoryQuotaInMB>0</DirectoryQuotaInMB>
</DirectoryConfiguration>
<DirectoryConfiguration>
<Path>C:\Resources\directory\8091b0be14e54213ac12fcbd5f9c8e1b.WebTestRole.DiagnosticStore\LogFiles</Path>
<Container>wad-iis-logfiles</Container>
<DirectoryQuotaInMB>16</DirectoryQuotaInMB>
</DirectoryConfiguration>
</Subscriptions>
</Directories>
In the original version the "BufferQuotaInMB" and "DirectoryQuotaInMB" fields were 0.
Note that after uploading the blob again the effect is not immediate. It takes a while for the changed configuration to get picked up, and then it takes another while before the IIS log files are copied for the first time.
Last note: it may be obvious, but I don't think editing that blob is a recommendable solution. It is good to know the option exists though.

Asp.net application error running with Sitecore 6.4.1

I have Sitecore as site root (which is running ok) and under it I need to have a bunch of asp.net applications running.
So far, created a virtual directory for the child application, turned it into an app. But as soon as I browse the child app it comes with this error message.
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0246: The type or namespace name 'Sitecore' could not be found (are you missing a using directive or an assembly reference?)
Source Error:
Line 3264: </providers>
Line 3265: </roleManager>
Line 3266: <profile defaultProvider="sql" enabled="true" inherits="Sitecore.Security.UserProfile, Sitecore.Kernel">
Line 3267: <providers>
Line 3268: <clear/>
It seems that the child asp.net app is inheriting Sitecore settings which are coming from Sitecore web.config.
Any ideas?
This should be possible. You'll have to author a web.config for that non-Sitecore application in virtual directory, and overwrite the sections under <system.web> and <system.webserver> which reference Sitecore classes. This includes:
httpModules / httpHandlers (for these you should "remove all" and add those of that web app)
security section (put the default ASP.NET provider classes back)
in Sitecore main web.config add the path of this web app to IgnoreUrlPrefixes setting to let Sitecore know it should not handle requests to those
It might be something else, but you should get the general idea.
This answer is similar to Yan, but is different enough for a separate answer. Hope it helps.
Go into IIS and select the Child Application. Select Modules. Remove all the Sitecore related modules that are present. Don't worry, the parent Sitecore app will still retain these modules.
When you do this, you are actually changing the child app web.config, so you will see the elements removed in the web.config file like so.
<remove name="SitecoreConfigWatcher" />
<remove name="SitecoreHttpModule" />
You also may have to clear out some other inherited settings.
<profile enabled="false"><providers><clear/></providers></profile>
<roleManager enabled="false"><providers><clear /></providers></roleManager>

Resources