How to receive/accept an xml file in MVC4 Application - asp.net-mvc-4

My requirement is iam working on Windows8 App, i need to send an Registration XML file to MVC4 Application which is acting as a service. Windows8 acts a client and MVC4 acts as Server.
In server there will be already an Registration xml file, i need to check with that xml file any Username is already exist or not. If exits then i need send message that "username already exists please chosse other username." If not then I have to add a extra node in the registration.xml at server.
So now i need the Code how to send an XML file as an object in Windows8 App and how to receive/accept xml file in MVC4 Application.

Why do you want to send and receive xml?
Just send the user registration info to the server using standard HTTP POST. Server will check the local xml file, and insert the new user info or return a validation error to the client.
No need to send XML back and fourth.
Also IMHO xml file storage is a poor choice for a server backend data store, the file should be locked frequently to avoid concurrency problems, which will cause performance issues.
My suggestion is to get a free database engine, or even better, Windows Azure Mobile Services.
If you insist, You can pass your xml as a regular string to an MVC action:
public ActionResult Validate(string xmlContent)
{
XDocument doc1 = XDocument.Parse(xmlContent);
//Do your manipulation here
}
Here is a link on how to manipulate XML in .NET
As for sending the xml to the server from Windows Phone, I think this answer helps.

Related

Azure File Storage the server responded with a status of 400 (Condition headers are not supported.)

I have some png files stored in Azure file Storage, and I'm retrieving and displaying it from my MVC web project to the browser. But sometimes I get the below error message from browser console.
Failed to load resource: the server responded with a status of 400
(Condition headers are not supported.)
If I refresh the page again, the error message disappears automatically. But it doesn't solve my problem as I run my MVC project again, the same error comes back. How to solve it?
It's acutally a common issue on Azure Storage, which be listed in the offical reference Common REST API Error Codes as the figure below.
It means that Get File REST API does not support those request headers which not be listed in the Request Headers.
There is a similar SO thread Azure File Storage Error: Condition Headers Are Not Supported, which got the same issue with yours. It seems to show up different behavior in different browses when you get a file from Azure File Storage.
I could not reproduce this issus by a file url with SAS token, but I really recommend that you need to store these static files like images on Azure Blob Storage, as I known and as Azure best practice, to show an image by its url with sas token or a public container.

How do I access Google Drive Application Data from a remote server?

For my application I want the user to be able to store files on Google Drive and for my service to have access to these same files created with the application.
I created a Client ID for web application and was able to upload/list/download files from JavaScript (client side) with drive.appfolder scope. This is good, this is half of what I want to do.
Now I want to access the same files from Node.js (server side). I am lost as to how to do this. Do I create a new Client ID for the server? (if so, how will the user authenticate?) Do I pass the AuthToken my user got client-side and try to use that on the server? I don't think this will work as the AuthToke is time-sensitive (and probably not intended to be used from multiple IPs).
Any direction or example server-side code will be helpful. Again, all I want is to access these same files the user created with my application, not any other files in the user's Google Drive.
CLARIFICATION: I think my question boils down to: "Is it possible to access the same Application Data on Google Drive both client-side and server-side?"
Do I create a new Client ID for the server?
Up to you. You don't need to, but you can. See below.
if so, how will the user authenticate?
Up to you. OAuth is about authorisation, not authentication.
Just in case you meant authorisation, the user authorises the Project, which may contain multiple client IDs.
Do I pass the AuthToken my user got client-side and try to use that on the server?
You can do, but not a good idea for the reason you state. The preferred approach is to have a separate server Client ID, and use that to request offline access, which returns (eventually) a Refresh Token, which you store in your server. You then use that Refresh Token to request Access Tokens whenever you need them.
AuthToken is ... (and probably not intended to be used from multiple IPs).
It is not bound to a specific IP address
Is it possible to access the same Application Data on Google Drive both client-side and server-side?"
Yes
Most of what you need is at https://developers.google.com/accounts/docs/OAuth2WebServer

WebApi json to csv client download

I need my application to hit the database, build up a list of my objects, format as csv string then return back to client javascript for client to download as a csv file.
Can this be done with MVC4 webapi controllers? Client is using IE8 so the method creating my own CsvFormatter class inheriting the MediaTypeFormatter then building up string and letting user save client side with the following is not possible as IE8 doesn't support the Download attribute.......
Any help appreciated.

Forms Based Authentication SharePoint 2010 using SSRS HTML viewer

I'm running SSRS in integrated mode (Trusted) and have an issue with trying to use the HTML viewer on a Forms Based Authentication site in Sharepoint 2010. I have found several articles on using the report viewer in FBA; however, to the best of my knowledge, I need to use the HTML viewer as the ultimate goal is to seamlessly produce a PDF file for the end user. The error I'm getting is "401 UNAUTHORIZED An unknown error occurred with the Reporting Services endpoint on this SharePoint site." The Url format I'm submitting is as follows:
http:///_vti_bin/ReportServer?//.rdl&rs:Command=Render&rs:Format=PDF. Some additional information, the request works if I use the default site name and not the forms based name.
So my question is twofold, should I be able to do this in FBA? and if not what is the best route to produce a PDF of the report for the client?
Thanks
First of all, running SSRS with SharePoint is tricky. For SSRS to be able to receive the user credential, it has to be running in kerberos mode. Otherwise, the request to SSRS is made as ANONYMUS LOGON (that's why you are getting a 401).
Now, for the PDF, you have a few options :
Call the SSRS webservice directly and produce a PDF.
Setup a subscription and generate it as PDF, either to filesystem, email, etc.
Do what you are doing now, but with kerberos enabled.

RavenDB: Windows user credentials not sufficient for write access

I'm trying to use the RavenDB server web/silverlight UI to create databases and test data, and am being asked for a username/password. This is fine, and the documentation on http://blogs.hibernatingrhinos.com/5/ravendb-in-practice-part-1-an-introduction-to-ravendb says that I should use my Windows credentials:
Be default RavenDB allow anonymous access only for read requests (HTTP GET), and since we creating data, we need to specify a username and password. You can control this by changing the AnonymousAccess setting in the server configuration file.
Enter your username and password of your Windows account and a sample data will be generated for you.
However the dialog reappears instantly. A few tries later and it fails with an authorisation error.
I'm using the Raven Silverlight client through Google Chrome Windows XP Home SP3, and haven't changed RavenDB's settings (I want it to work with authentication, rather than dodging the issue).
1) Make sure you give user permissions to read/write in the directory where raven is installed.
2) Make sure that you have set in web.config
3) Check this thread RavenDB Network Access