Session Value not persisted in Azure App Service - azure

Session not persisted in Azure App Service
I have a Web Application in Asp.net MVC, I used to set the session. When I click a LoginButton
Session["FlowType"] : "Auth"
Now the request goes to IdentityServer and during Callback on
I tried to retrieve the session Session["FlowType"] and it gave me null value.
I checked the Azure Affinity Cookie too. It is same, when I checked in fiddler.
Can someone help me with this.

First, make sure the strings is same like 'FlowType'.
Second,you can try to debug your code like below.
Session["FlowType"]="aaa";
string test = Session["FlowType"].ToString();
Check the value of 'test', is null or 'aaa'. If the value of test is correct,maybe you can print Ctrl+Alt+i to open the Immediate Window in Visual Studio. Then you can check when the Session is missing.
The last Step,maybe you can modfiy your web.config to set config about the Session.
I hope the above answers can help you.
Add Pic
How to debug in azure. You also can google it.
step 1: Make sure publish configuration setting. Like pic bellow
step 2: When publish succeed,you can attach debugger
My IDE is vs2019, you can click View-> Cloud Explore ,then you find you sourcegroup and web app.
Like pic, you find it , and click, it will show Attach Debugger, then you
debugger in azure to test.
3. The first debugging will take a long time.

Related

Azure Web App - Cannot GET (particular path)

I have been trying out the AADv2 sample from BotAuth to no avail.
The error that I keep getting after I select the button on the action card is that either a HTTP 500 internal server error, or Cannot GET /botauth/aadv2. When I check if the root web page or the messaging endpoint is working or not, I get the same error - either Cannot GET / or Cannot GET \api\messages. The root page I have been trying to get to is https://(botname).azurewebsites.net
May I know what steps I can take to resolve this issue? I have tried to Google the error, but to no avail. Please let me know if you need more information!
Since you are test the sample directly on Azure Web Apps, there should be a few of questions we should pay attention on.
1, const MICROSOFT_APP_ID = envx("MICROSOFT_APP_ID");
const MICROSOFT_APP_PASSWORD = envx("MICROSOFT_APP_PASSWORD");
we declare the environment valiable as MicrosoftAppId and MicrosoftAppPassword. Please modify this sentence as
//bot application identity
const MICROSOFT_APP_ID = envx("MicrosoftAppId");
const MICROSOFT_APP_PASSWORD = envx("MicrosoftAppPassword");
2, And you also need to check the environment variables are set correctly in Application settings of Azure Web App, which is shown at https://github.com/MicrosoftDX/botauth/tree/master/Node/examples/aadv2#3-setup-environment-variables
3, You can leverage online code editor to develop, debug, and manage your project on Azure Web Apps.
And in the output column, you can see the detailed errors throwm by the application. You can leverage these info to narrow down your issue.
Tips, after you changing the application settings, it's better to restart your Azure Web App.

Just created Azure Mobile App service calls return http 400 error

Here's what I'm doing.
Install latest Azure SDK (by the date)
Open Visual Studio 2013
Create a new Azure Mobile App project. The simple service is created with TodoItem DataObject and 2 simple controllers - TodoItemController and ValuesController
Do not change anything
Start the project
The service is started and hosted in local IISExpress on url http://localhost:50993/ (the port may vary).
The "This mobile app is up and running" web page is opened in the browser. But http 400 error is returned when I try to invoke some GET-actions: for example http://localhost:50993/api/values or http://localhost:50993/tables/TodoItem.
Any ideas? Is something wrong in my environment or is that me doing something wrong?
Thanks.
I guess you can opt out of version checking by setting a value of true for the app setting MS_SkipVersionCheck. Specify this either in your web.config or in the Application Settings section of the Azure Portal.
This generally happens when you don't add a ZUMO-API-VERSION header to the request. This is required when making requests from a REST client, but the mobile client SDKs add the header automatically.
To fix, add the header ZUMO-API-VERSION with value of 2.0.0.
To learn more, see https://azure.microsoft.com/en-us/documentation/articles/app-service-mobile-client-and-server-versioning/.
Adding
http://localhost:50993/tables/Location?ZUMO-API-VERSION=2.0.0
at the end will do the trick.

Kiip web sdk integration showing bad request error in console

I just integrated KIIP SDK for web in my node js application and it works correctly . But the problem is it showing error on browser console on each page refresh, But this error does not affect working of this sdk, it works perfectly.
the errror message showing is,
'POST https://api.kiip.me/2.0/web/moment/?r=1426508956613 400 (Bad Request)'.
My kiip code integration is as follows,
1) Included the script file on head tag
2)Declared the app key as global variable,
kiip_app_key='app-key from kiip site';
3) And intialized the kiip instance and invoked the method.
var kiipInstance = new Kiip(kiip_app_key);
kiipInstance.setTestMode();
kiipInstance.postMoment('received offer');
Andrew from Kiip here.A few things could be causing this:
The page is running from a local file or host. Solution: run the test page on a server.
The app is not submitted for live rewards. Solution: Submit for live rewards in the Kiip dashboard.
You're passing an incorrect app key. Solution: copy the app_key for the corresponding app from the Kiip dashboard and paste it as you're global variable.
Hope this helps,
Andrew

how to view azure diagnostics Log

I am not able to find out how to see azure diagnostics logs. Code which I wrote is as follows.
DiagnosticMonitorConfiguration config = iagnosticMonitor.GetDefaultInitialConfiguration();
System.Diagnostics.Trace.Listeners.Add(new Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener());
config.Logs.ScheduledTransferLogLevelFilter = LogLevel.Information;
config.WindowsEventLog.ScheduledTransferPeriod = System.TimeSpan.FromMinutes(1.0);
DiagnosticMonitor.Start("Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString", config);
then I added Trace.WriteLine("some message"); in the code. Now where do I find those messages. I checked in Visual Studio server explorer, where I added my storage account reference. wad-control-container has only config files.
You might want to take a look at this blog post by Michael S. Collier. A setting in your cloud project might cause the logs to end up in an other place than you would expect them to:
http://michaelcollier.wordpress.com/2012/04/02/where-is-my-windows-azure-diagnostics-data/
Update:
Note that you'll have to take care of every small detail to make everything work.
Where are you writing Trace.WriteLine("some message"); ? Is it in your WebRole.cs? If that's the case, you'll need to configure the trace listener for the WebRole.cs (this runs in an other process, different than your actual web application).
Here is an example how you can set up the trace listener in the WebRole.cs class:
System.Diagnostics.Trace.Listeners.Add(new Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener());
System.Diagnostics.Trace.AutoFlush = true;
After setting that up, you can use Trace.WriteLine.
This is a good step by step on how to enable diagnostics:
http://www.windowsazure.com/en-us/develop/net/common-tasks/diagnostics/?sec=commontasks
I wrote a tool that allows you to view Azure Diagnostic information.. check it out
AzTools - Azure Diagnostic Viewer
Click here to see how you could use this tool

How to launch a console application from an IIS based web service, and have it visible while processing?

I'm trying to launch a console app from an IIS based web service, but its not visible on the server.
Code so far is:
string downloaderPath = ConfigurationManager.AppSettings["DownloaderExePath"];
System.Diagnostics.ProcessStartInfo si = new System.Diagnostics.ProcessStartInfo();
si.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
si.FileName = downloaderPath;
si.UseShellExecute = true; //false doesn't make a difference
System.Diagnostics.Process.Start(si);
The process fires, but with errors. Would like to have it visible on the screen, is this possible?
I don't think there is anything in the .Net BCL that would allow you to do so, even if it is at all possible.
You would need to start the application in the current 'interactive' user session. When starting the app from the webservice, it is running in the session of IIS (as a service).
Perhaps looking at tools like psexec might shed some light on how to get this working.
Alternatively, log the errors to a file and/or attempt to hook up a debugger to the iis
process (w3wp.exe)

Resources