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.
Related
I'm using Auth0 to manage authentication in a web app.
Since it took me a while to get it working, I'd like to export the application and API settings like for example:
the application name
the client id
the supported auth methods
the allowed callback URLs
basically everything else relevant to reproduce the application configuration
I found a lot of documentation about exporting user data but nothing about exporting application or API settings.
Generally, the steps described here are just a quick&dirty workaround to read data from the Auth0 Management API without leaving your browser. I wonder why there is no "export" button for this directly in the UI. In both cases (application and API settings), open the network monitoring tab of your browser (usually F12); Then...
Exporting Application Settings
Load the "settings" page of the application you'd like to export (e.g. https://manage.auth0.com/dashboard/eu/<your_auth0_tenant_name_here>/applications/<your_application_client_id_here>/settings)
You'll see a GET request to manage.auth0.com/api/clients/<your_application_client_id_here>.
The response to this GET request is a JSON containing everything you need to reproduce the application settings; also sensitive data like the client secret and signing keys.
Exporting API Settings
Load the "settings" page of the API you'd like to export (e.g. https://manage.auth0.com/dashboard/eu/<your_auth0_tenant_name_here>/apis/<your_api_id_here>/settings)
You'll see a GET request to manage.auth0.com/api/resource-servers/<your_api_id_here>.
The response to this GET request is a JSON containing everything you need to reproduce the API settings.
I want to change app service's response content-type from application/json to application/xml. One solution I come across is this but it didn't explain how to configure ABP and use Xml Formatter. Can anyone please explain how to configure ABP for this package i.e Microsoft.AspNetCore.Mvc.Formatters.Xml. Simply installing this package and configuring startup.cs file with services.AddMvc().AddXmlSerializerFormatters() didn't work. I think ApplicationCoreModule has to be configured. Btw My app service is returning a list of objects.
Here are the images of Results when I execute API in Swagger:
Request Image
Response Image
Assume we have an web application where user will be provided an option to upload folder/file
Assume we have created an IAM and configured FTP to access S3 via FTP.
Now the user can upload a folder/file via FTP or web application.
We need to create a event notification or call a rest api whenever a new folder or file has been uploaded.
How to register an event register and call the rest API whenever a new folder or file has been uploaded?
How to differentiate whether the upload or file has been done from web application or FTP server from S3 ?
We need to call a different api when the folder has been created via web application and we need to call a different api when the folder has been created via FTP server
Thanks.
1) You can register to an object created event using lambda function via the properties of the bucket(ObjectCreated(All) event), and then execute a call to your API.
2) You can add a metadata to you file while uploading it saving the source of the upload. For example in your http request add the following header x-amz-meta-filesource. Every header starting with x-amz-meta- will be saved as the file metadata.
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.
I have a php/apache service and meteor on the same server. I am using the accounts-ui package.
Is there anyway to know in my php script, that a user is logged in, given the login token (session id?)
This is my original need: upload a profile picture for a logged in user.
Very simple right? But I have not found an answer after hours of googling.
First solution would be using html5 File apis to send data to meteor server and the server save the image. But this solution wont even work for IE9.
Second solution is what I am trying: Using a html form to upload picture to a php script (or whatever script, it can be a nodejs script if needed). This script will save the image like a traditional php script does. The thing is I cannot know if the upload request is authorized, otherwise everybody can change profile picture of anybody. I must add some information in the upload request and verify them in the php code before saving the image. I am thinking about sending a request from php script to meteor server but I need to know which parameters to send and how meteor responses it.
How can I achieve the second solution or if someone has a another solution for my origin problem that would be great.
Thank you.
Meteor uses an a protocol called DDP to communicate between the client and server. But as of now there isn't a PHP ddp client so you would have to use a REST type communication method between your meteor server and your PHP server.
If you feel you could build a PHP client for your meteor client, it would greatly help you as you could do stuff like run Meteor.call from your php scripts and have them subscribe to collections. The full DDP spec (pre1) can be found at : https://github.com/meteor/meteor/blob/master/packages/livedata/DDP.md
To do a REST method you should use Meteor Router to allow you to create server side routes. It is installed via meteorite which helps you access a list of community packages at [atmosphere.meteor.com].1
sever side js
Meteor.Router.add('/checklogin', 'post', function() {
var userId = this.params.userId;
var loginToken = this.params.loginToken;
if(userId && loginToken) {
return (!!Meteor.findOne({_id:userId,"services.resume.loginTokens.token":loginToken}));
}
});
You can then do a POST request with PHP to /checklogin with two params, one is userId which is the userId (found with Meteor.userId() or localStorage.getItem("Meteor.userId"). The other is the login token found via localStorage.getItem("Meteor.loginToken") on your Meteor client.