I have an ActionResult that returns XML for an embedded device. The relevant code is:
return Content(someString, "text/xml", Encoding.UTF8);
Even though UTF-8 is specified, the resulting XML is:
<?xml version="1.0" encoding="utf-16"?>
The ASP.NET MVC is compiled as AnyCPU and runs on a Windows 2008 server.
Why is it not returni...
Hi there,
Attempting to use asp.net mvc's Action Result of File.
So it would seem that I have to specify a ContentType for the file to be sent to the browser. Currently there is no real limit to what types of files may be sent to the browser in my application, so I can't always assume it will be a "text/pdf", for example.
What's the b...
We have a pluggable framework that returns ActionResult objects that render things to a browser. One late breaking requirement is that our plugins should be callable from a regular ASP.NET Web Forms application.
So far I have come up with this, which works for very basic ActionResults:
public class ActionResultTranslator {
HttpCo...
Hi,
In a controller action, I am manually sending a form to a remote URL using WebRequest. I successfully receive a WebResponse containing an html page to display. I would like to "paste" this response as the Response (of type HttpResponseBase) of the action. An action normally returns an ActionResult, so how do I conclude my controller...
Idea is to use same action methods for different types of results
I.E.
/category/details/?resultFormat=json
/category/details/?resultFormat=xml
So to have some kind of ActionResult helper that contains registered pairs of value resolvers
"json", JsonValueResolver
"xml", XmlResolver
etc...is there already solution fo...
I have a not-so-ideal situation where uploaded files are stored on an internal network share. So in the database I'm storing the path to where the file was saved, but it's quite possible for the file to get deleted out of sync of the database. So in a Controller action I lookup the upload information and perform checks that things are ...
Using the following sample: http://www.west-wind.com/Weblog/posts/899303.aspx
The following line...
return req.RedirectingResponse.AsActionResult();
renders the string "DotNetOpenAuth.Messaging.OutgoingWebResponseActionResult".
This is the class being returned as ActionResult in the line as posted. Does anyone know why I get the clas...
How do you set the result of an action result to use Post and not Get.
I need to redirect the result to an external site that requires the data to be sent using the post method.
(Would like to know also how to redirect to another action with a httpverbs.post filter - but not as important for me at this point).
...
For instance if I wanted to unit test the following controller what do I replace ???? with?
using System.Web.Mvc;
namespace MvcApplication1.Controllers
{
public class StatusController : Controller
{
public ActionResult Index()
{
return Content("Hello World!");
}
}
}
[TestMethod]
public v...
I have a View that displays a list of images and i am now trying to get it to display the images as thumbnails. Well, i'm pretty sure i got most of it right using VirtualPath's from a custom ActionResult although i can't seem to figure out what it is making the VirtualPath url?? BTW, i'm using XML to store the data from the images inst...
I have a method that figures out what to do with a user after
protected override ActionResult RedirectFromReg1(IPrincipal u)
{
if something....
{
return RedirectToAction("LogIn", "Account");
}
return null;
}
The calling code then ret...
i have a controlled called AppController.
i have 2 actions: Details and Delete
both pass in int id as the parameter to the action
WHen i go to:
mysite/App/Details/100
I can catch it in the controller details action but when i go to
mysite/App/Delete/100
The breakpoint never hits and i get this in the browser:
Server Error in '...
I'm noticing some behavior that I don't like, and I'm wondering if this is normal.
I've got a BaseController that is Inheriting from Mvc.Controller, and I've got a View function inside that is to fire on every page load.
Protected Overrides Function View(ByVal viewName As String, ByVal masterName As String, ByVal model As Object) As ...
Whats the simplest way of just returning an int from an Ajax MVC Action call?
I am currently trying:
public ContentResult Create(MyModel model)
{
return Content("1");
}
using (Ajax.BeginForm("Create",
new AjaxOptions {
OnComplete = "function(data) { alert(data); }"
}))
I get alert [object Object]. How...
I'm running into a strange issue in more than one page of my ASP.NET MVC site. When I POST a form and the Model is NOT valid, I try to return the same view so that I can see the errors - however, instead of the page getting reloaded, I get a pop-up download box that says that the file is in "application/json" format. As you can see fro...
Hey!
I have a scenario where the user have the option to click the button "download" and I should create a csv file, that contains history data, and then let the user save the file locally. As I haven't done this before, I started to look around for how to do this and basically came across both Custom View Engine, and Custom Action Resu...
I am workingon an MVC route that will take an unknown number of parameters on the end of the URL. Something like this:
domain.com/category/keyword1/keyword2/.../keywordN
Those keywords are values for filters we have to match.
The only approach I can think of so far is UGLY... just make an ActionResult that has more parameters than I ...
I'm trying to unit test a custom action result. I recently watched Jimmy Bogard's excellent MvcConf video ("put your controllers on a diet") http://www.viddler.com/explore/mvcconf/videos/1/ and have started to try and implement some custom action results. I've managed that without a problem, the ActionResult works fine at runtime but I'm...
I have a HTTPService:
<mx:HTTPService id="scoreService" url="http://" method="POST" result="onResult(event)">
<s:request xmlns="">
<name>{..}</name>
<score>{...}</score>
</s:request>
</mx:HTTPService>
And a script for (event):
private function onResult(e:ResultEvent):void
{
...
Here are the files -
MXML:
<mx:HTTPService id="score" url="http://...score.php" fault="mx.controls.Alert.show(event.fault.faultString)"
method="POST" result=""mx.controls.Alert.show(event.result.toString())">
<s:request xmlns="">
<name>{name}</name>
<score>{score}</score>
</s:requ...