can't get web page source from url in Swift - swift

I'm currently using SwiftHTTP for getting source of url address. I am using 'get method' for getting source code of url address which is
do {
let opt = try HTTP.GET(self.my_url_address!)
opt.start { response in
if let err = response.error {
print("error: \(err.localizedDescription)")
return
}
print(response.description)
}
} catch let error {
print("got an error creating the request: \(error)")
}
after this code run I got this output in Xcode output screen
URL: http://myweburl.com/detay/swat-under-siege.html
Status Code: 200
Headers: Content-Type: text/html
Connection: keep-alive
CF-RAY: 38391215a60e2726-FRA
Set-Cookie: ASPSESSIONIDSABBBSDT=HPKKPJGCDLKMDMILNGHPCAGD; path=/
Date: Mon, 24 Jul 2017 18:51:24 GMT
Vary: Accept-Encoding
X-Powered-By: ASP.NET Transfer-Encoding: Identity
Server: cloudflare-nginx
Content-Encoding: gzip
Cache-Control: private
The status code is 200 but the output is not the source code of url. How can I fix this?

Response is correct. I've tried requesting the website (the real one) and it works:
print(response.data.base64EncodedString())
If you decode the BASE64 data, it will render valid HTML code.
The issue seems related to encoding. After checking the website's head tag, it states that the charset is windows-1254
String(data: response.data, encoding: .windowsCP1254) // works. latin1, etc.
Your issue is similar to SWIFT: NSURLSession convert data to String

Related

How to check if the API return nothing with Alamofire?

I am using Alamofire to make an API request to insert user data to my database, if the user email is exist, the response will return
[Response]:
[Status Code]: 200
[Headers]:
Connection: Keep-Alive
Content-Length: 27
Content-Type: text/html; charset=UTF-8
Date: Thu, 22 Apr 2021 06:39:05 GMT
Keep-Alive: timeout=5, max=99
Server: Apache/2.4.25 (Debian)
[Body]:
Email address already exist
[Network Duration]: 0.013917088508605957s
[Serialization Duration]: 0.0s
[Result]: success(Optional(27 bytes))
and if user email is not exist, it will insert data to the database, and return nothing like this
(literally nothing, there's no character or whatsoever, just a blank page if I open the api in the web browser)
And here is the response
[Response]:
[Status Code]: 200
[Headers]:
Connection: Keep-Alive
Content-Length: 0
Content-Type: text/html; charset=UTF-8
Date: Thu, 22 Apr 2021 06:54:43 GMT
Keep-Alive: timeout=5, max=100
Server: Apache/2.4.25 (Debian)
[Body]: None
[Network Duration]: 0.8882529735565186s
[Serialization Duration]: 0.0s
[Result]: success(nil)
Now I want to make a validation to check if user email is exist or not by checking the response body. if the response body is Email address already exist, it will display an error alert. and if response body is None, it will display a successful alert. My question is, how do I check if the response body is None? here is validation code
let parameters = ["USERNAME": "\(USERNAME)", "EMAIL": "\(EMAIL)", "FULL_NAME": "\(FULL_NAME)", "NO_TELEPON": "\(NO_TELEPON)", "PASSWORD": "\(PASSWORD)", "USER_TOKEN": "\(USER_TOKEN)"]
AF.request("http://172.16.5.56:8081/User/InsertNewUser", parameters: parameters).response{ response in
debugPrint(response)
if let data = response.data, let utf8Text = String(data: data, encoding: .utf8){
print(utf8Text)
postResponse = utf8Text
if postResponse == "Email address already exist" {
self.haptics.notificationOccurred(.error)
self.activeAlert = .first
self.showAlert = true
}else if postResponse == "None"{ // This is not working
self.haptics.notificationOccurred(.success)
self.activeAlert = .second
self.showAlert = true
}
}
}
The response (as you shared) in fail-type case is:
[Response]:
[Status Code]: 200
[Headers]:
Connection: Keep-Alive
Content-Length: 0
Content-Type: text/html; charset=UTF-8
Date: Thu, 22 Apr 2021 06:54:43 GMT
Keep-Alive: timeout=5, max=100
Server: Apache/2.4.25 (Debian)
[Body]: None
[Network Duration]: 0.8882529735565186s
[Serialization Duration]: 0.0s
[Result]: success(nil)
Shows [Result]: success(nil) which means the response.data is literally nil.
I propose the following solution:
Alamofire
.request("http://172.16.5.56:8081/User/InsertNewUser")
.response { (response) in
if let data = response.data,
let string = String(data: data, encoding: .utf8) {
if string == "Email address already exist" {
self.haptics.notificationOccurred(.error)
self.activeAlert = .first
self.showAlert = true
}
//else if ... {
//handle other cases
//}
} else {
self.haptics.notificationOccurred(.success)
self.activeAlert = .second
self.showAlert = true
}
}
NOTE: I would advise against direct string comparisons unless unavoidable.
Atleast agree on a common response template and ensure the responses are not prone to typos or silly mistakes.
#staticVoidMan has already provided a solution for your current backend setup. However, if you update your backend to return more appropriate responses, Alamofire can do a lot more for you automatically.
In short, you need to make your backend behave in a standard fashion following JSON API best practices. These include:
In the failure case, return a failure status code (probably 403), and a JSON payload describing the error.
In the success case, you could return a 201, which indicates the new user has been created, in which case you should include the new user object JSON in the response, or a 204, which is the proper status code for an empty response.
In these cases you can define proper Decodable payloads which Alamofire can parse for you, as well as a proper value for the empty responses, and Alamofire will ensure it's returned in the 204 case.

Upload file to Box.com via RESTful API using NSURLSession / Swift 2.0

I would like to upload a log file from our iOS app directly to a folder on Box.com. Reading the api for Box this functionality is provided with REST webservices. The examples in the api are cURL which work out of the box (sorry, no pun intended) from the terminal.
Our app is Swift based, and I am using NSURLSession to make the request. After too many attempts to count, and close examination of the limited blogs on this subject (iOS / Box) I still have not managed to upload a test file.
One frustrating thing is that the api appears to be wrong, as seen here, but following the format suggested in this answer did not help.
Here is the NSURLSession request code from my latest attempt:
let path = NSBundle.mainBundle().pathForResource("testFile", ofType: "txt")
let data: NSData? = NSData(contentsOfFile: path!)
let url = NSURL(string: "https://upload.box.com/api/2.0/files/content")!
let request = NSMutableURLRequest(URL: url)
let boundary = generateBoundaryString()
request.HTTPMethod = "POST"
request.addValue("Bearer q1ckXDSTC0EcsCJiLtW638o5x5roWabb", forHTTPHeaderField: "Authorization")
let body = NSMutableData()
body.appendData("Content-Type: multipart/form-data; boundary=\(boundary)\n".dataUsingEncoding(NSUTF8StringEncoding)!)
body.appendData("--\(boundary)\n".dataUsingEncoding(NSUTF8StringEncoding)!)
body.appendData("Content-Disposition: form-data; name=\"parent_id\"\n".dataUsingEncoding(NSUTF8StringEncoding)!)
body.appendData("Content-Type: text/plain\n".dataUsingEncoding(NSUTF8StringEncoding)!)
body.appendData("0\n".dataUsingEncoding(NSUTF8StringEncoding)!)
body.appendData("--\(boundary)\n".dataUsingEncoding(NSUTF8StringEncoding)!)
body.appendData("Content-Disposition: form-data; name=\"filename\"; filename=\"testFile.txt\"\n".dataUsingEncoding(NSUTF8StringEncoding)!)
body.appendData("Content-Type: text/plain\n".dataUsingEncoding(NSUTF8StringEncoding)!)
body.appendData(data!)
body.appendData("\n--\(boundary)--".dataUsingEncoding(NSUTF8StringEncoding)!)
request.HTTPBody = body
let task = NSURLSession.sharedSession().uploadTaskWithRequest(request, fromData: data!, completionHandler: {(data,response,error) in
if(error != nil) {
NSLog("Error message = \(error.debugDescription)")
}
if(response != nil) {
NSLog("Response = \(response)")
}
if(data != nil) {
NSLog("Data = \(data!)")
}
});
task.resume()
The server responds with a 405 error.
Response = Optional(<NSHTTPURLResponse: 0x157de26d0> { URL: https://upload.box.com/api/2.0/files/content } { status code: 405, headers {
Age = 0;
Allow = "GET, OPTIONS, HEAD";
Connection = "keep-alive";
"Content-Length" = 0;
"Content-Type" = "text/html; charset=UTF-8";
Date = "Thu, 13 Oct 2016 14:49:49 GMT";
Server = ATS;
} })
From the example above the request header is:
Request headers - Optional(["Authorization": "Bearer q1ckXDSTC0EcsCJiLtW638o5x5roWabb"])!
And the request body is:
body - Content-Type: multipart/form-data; boundary=0B1D5883-9EA6-4D6B-9FEC-C51D817D5975
--0B1D5883-9EA6-4D6B-9FEC-C51D817D5975
Content-Disposition: form-data; name="parent_id"
Content-Type: text/plain
0
--0B1D5883-9EA6-4D6B-9FEC-C51D817D5975
Content-Disposition: form-data; name="filename"; filename="testFile.txt"
Content-Type: text/plain
Hello
--0B1D5883-9EA6-4D6B-9FEC-C51D817D5975--
We have tried to disseminate the cURL request with Wireshark but as it is an SSL request this didn't help much.
The verbose version of the cURL request looks like this:
0000: POST /api/2.0/files/content HTTP/1.1
0026: Host: upload.box.com
003c: User-Agent: curl/7.47.0
0055: Accept: */*
0062: Authorization: Bearer o6ojjxpfECdKrBzIUhiRyRKHTTXg8Sll
009a: Content-Length: 368
00af: Expect: 100-continue
00c5: Content-Type: multipart/form-data; boundary=--------------------
0105: ----ed667cff7b6570a1
011b:
== Info: Done waiting for 100-continue
=> Send data, 285 bytes (0x11d)
0000: --------------------------ed667cff7b6570a1
002c: Content-Disposition: form-data; name="attributes"
005f:
0061: {"name":"testFile.txt", "parent":{"id":"0"}}
008f: --------------------------ed667cff7b6570a1
00bb: Content-Disposition: form-data; name="file"; filename="testFile.
00fb: txt"
0101: Content-Type: text/plain
011b:
=> Send data, 35 bytes (0x23)
0000: This is a test file.
=> Send data, 48 bytes (0x30)
0000:
0002: --------------------------ed667cff7b6570a1--
Which we have also tried to replicate exactly, but the problem remains.
If anyone has achieved this successfully I would really appreciate some direction or suggestions
We contacted Box support team but they have yet to respond.

Angular2 Http Response missing header key/values

I'm making an http.patch call to a REST API that is successful (Status 200) but not all the response headers key/values are being returned. I'm interested in the ETag key/value.
Here is a code snippet:
let etag:number = 0;
let headers = new Headers();
headers.append('Content-Type', 'application/json');
headers.append('If-Match', String(etag));
this.http.patch(
'http://example.com:9002/api/myresource/',
JSON.stringify(dto),
{headers: headers}
)
.subscribe(
(response:Response) => {
let headers:Headers = response.headers;
let etag:String = headers.get('ETag');
console.log(etag);
}
);
When making the same call with a REST Client (Postman), the response header contains:
Content-Type: application/hal+json;charset=UTF-8
Date: Mon, 01 Feb 2016 05:21:09 GMT
ETag: "1"
Last-Modified: Mon, 01 Feb 2016 05:15:32 GMT
Server: Apache-Coyote/1.1
Transfer-Encoding: chunked
X-Application-Context: application:dev:9002
Is the missing response header key/values a bug?
Can the issue be resolved with configuration?
This isn't an Angular issue, rather a CORS one. By definition, CORS will only return six "simple" headers: Cache-Control, Content-Language, Content-Type, Expires, Last-Modified and Pragma.
That's why you see the full set when using a REST client such as Postman, yet when calling from your Angular client, you'll only see the set limited by CORS.
To solve this, you'll need to add an Access-Control-Expose-Headers header along the following lines:
let headers = new Headers();
headers.append('Access-Control-Expose-Headers', 'etag');
let options = new RequestOptions({ headers: headers });
return this.http.get(uri, options).map(this.extractData).catch(this.catchError);
Note that you may need to augment the server side code to support the required exposed headers.
In my case (C#), I revised the EnableCors call (within WebApiConfig) to include "ETAG" in the list of exposed headers (the fourth parameter of the EnableCorsAttribute function).

NSURLRequestCachePolicy.UserProtocolCachPolicy requirements

I am using the following code for caching, the response received form the server has the following headers. Is there any header that needs to be set from the request side, for the caching to work for 10 seconds of age.
Connection Received Resopnse Headers= [Date: Sat, 12 Sep 2015 22:51:16
GMT, Transfer-Encoding: Identity, Server: Apache-Coyote/1.1,
Content-Type: application/json;charset=UTF-8, Expires: Sat, 12 Sep
2015 22:51:26 GMT, Cache-Control: max-age=10, must-revalidate]
The mighty code which is not caching.
import UIKit
class HTTPJSONDonwload: NSObject , NSURLConnectionDataDelegate , NSURLConnectionDelegate {
static let httpjsonDownloader:HTTPJSONDonwload = HTTPJSONDonwload()
func startDownload(){
let serverRequest = getServerURL()
NSURLConnection(request: serverRequest, delegate: self, startImmediately: true)
}
func getServerURL() -> NSMutableURLRequest{
let request:NSMutableURLRequest = NSMutableURLRequest(URL:NSURL(string:"http://citiesfav-jcitiesj.rhcloud.com/Cache/getAllCities")! )
request.cachePolicy = NSURLRequestCachePolicy.UseProtocolCachePolicy
request.HTTPMethod = "POST"
return request
}
func connection(connection: NSURLConnection, didReceiveData data: NSData) {
print("Connection Data= \(NSString(data: data, encoding: NSUTF8StringEncoding))")
}
func connection(connection: NSURLConnection, didReceiveResponse response: NSURLResponse) {
print("Connection Received Resopnse Headers= \((response as! NSHTTPURLResponse).allHeaderFields)")
}
func connection(connection: NSURLConnection, willCacheResponse cachedResponse: NSCachedURLResponse) -> NSCachedURLResponse? {
print("Connection will cache Response")
return cachedResponse
}
}
After removing must-revalidate from the header it was still fetching the request.
Connection Received Resopnse Headers= [Cache-Control: max-age=10,
Transfer-Encoding: Identity, Date: Sun, 13 Sep 2015 18:35:43 GMT,
Content-Type: application/json;charset=UTF-8, Server:
Apache-Coyote/1.1, Expires: Sun, 13 Sep 2015 18:35:53 GMT]
Later findings show the POST request does get cached, but does not work like GET, where max-age is considered.
func startDownload(){
let serverRequest = getServerURL()
let cache = NSURLCache.sharedURLCache()
let response = cache.cachedResponseForRequest(serverRequest)
if response != nil {
serverRequest.cachePolicy = NSURLRequestCachePolicy.ReturnCacheDataDontLoad
}
NSURLConnection(request: serverRequest, delegate: self, startImmediately: true)
}
tl;dr
You need to use GET instead of POST.
Lengthy Explanation
The issue is that you're request is a POST.
func getServerURL() -> NSMutableURLRequest{
...
request.HTTPMethod = "POST"
...
}
In general, POST requests are used to create (or sometimes also to update) a resource on the server. Reusing the cached response for a creation or update request doesn't make much sense because you have to send the request to the server anyway (otherwise nothing is going to be created or updated). It seems that iOS automatically circumvents the cache on POST requests.
In your particular case, however, you don't really need the POST because you're merely reading data from the server. That means you should use a GET request instead.
func getServerURL() -> NSMutableURLRequest{
...
request.HTTPMethod = "GET"
...
}
I verified that the iOS system actually reuses the cache with the following snippet.
let d = HTTPJSONDonwload()
// Initial request. Can not reuse cache.
d.startDownload()
// Subsequent request after 5 seconds. Should be able to reuse the cache.
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, Int64(5 * NSEC_PER_SEC)), dispatch_get_main_queue()) {
d.startDownload()
}
// Subsequent request after 11 seconds. Cannot reuse the cache because
// the expiration timeout is 10 seconds.
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, Int64(11 * NSEC_PER_SEC)), dispatch_get_main_queue()) {
d.startDownload()
}
When I run this in the simulator and monitor the network calls with Charles Proxy, I indeed only see two events:
The first call is the initial request
and the second call is the third request which was issued after a delay of 11 seconds.
Note that the second request, which was issued after 5 seconds, does not appear which means that the response was retrieved from the cache. The delegate methods of NSURLConnection will, however, still be called just as if the response came from the network. With the logging output in your code you'll, therefore, see all three requests on the console.
Connection Received Resopnse Headers= [Server: Apache-Coyote/1.1, Content-Type: application/json;charset=UTF-8, Keep-Alive: timeout=15, max=100, Proxy-Connection: Keep-alive, Date: Mon, 14 Sep 2015 06:28:05 GMT, Content-Encoding: gzip, Content-Length: 36, Cache-Control: max-age=10, Vary: Accept-Encoding]
Connection Data= Optional({"1":"New York"})
Connection will cache Response
Connection Received Resopnse Headers= [Server: Apache-Coyote/1.1, Content-Type: application/json;charset=UTF-8, Keep-Alive: timeout=15, max=100, Proxy-Connection: Keep-alive, Date: Mon, 14 Sep 2015 06:28:05 GMT, Content-Encoding: gzip, Content-Length: 36, Cache-Control: max-age=10, Vary: Accept-Encoding]
Connection Data= Optional({"1":"New York"})
Connection Received Resopnse Headers= [Server: Apache-Coyote/1.1, Content-Type: application/json;charset=UTF-8, Keep-Alive: timeout=15, max=99, Proxy-Connection: Keep-alive, Date: Mon, 14 Sep 2015 06:28:16 GMT, Content-Encoding: gzip, Content-Length: 36, Cache-Control: max-age=10, Vary: Accept-Encoding]
Connection Data= Optional({"1":"New York"})
Connection will cache Response
Note that there is no Connection will cache Response after the second request because the response was retrieved from the cache and there is no point in caching it again.

500 Server Error HTML returned from MVC AJAX call when plain text specified

I am trying to return plain text from my MVC AJAX methods that indicates an error code. This is working fine on my dev machine, but when deployed to a server (Win2008 R2) I am always getting the HTML of the 500.htm page back in the error.responseText from my AJAX call instead of the text I specified. Any ideas why I would not get back the plain text I intended?
Here is my error handling logic in my controller.
protected override void OnException(
ExceptionContext filterContext
)
{
try
{
Error error = ControllerCommon.ProcessException(filterContext);
// return error
filterContext.Result = HandleError(error.Type);
filterContext.ExceptionHandled = true;
}
catch (Exception ex)
{
Logger.Instance.LogImportantInformation(ex.Message, 0, Constants.EventSourcePortal);
}
}
#endregion
#region Private Methods and Members
private ActionResult HandleError()
{
return HandleError(Error.ErrorType.Unknown);
}
private ActionResult HandleError(
Error.ErrorType errorType
)
{
// set return status code
HttpContext.Response.StatusCode = (int)HttpStatusCode.InternalServerError;
Logger.Instance.LogImportantInformation(((int)errorType).ToString(CultureInfo.InvariantCulture), 0, Constants.EventSourcePortal);
// return error type
return Content(((int)errorType).ToString(CultureInfo.InvariantCulture), "text/plain");
}
Here is the header that I get back from the Server.
Response Headers
Cache-Control private
Content-Type text/html
Server Microsoft-IIS/7.5
X-AspNet-Version 4.0.30319
X-Powered-By ASP.NET
Date Mon, 20 Jun 2011 16:00:42 GMT
Content-Length 1208
Request Headers
Host pqompo2test01.dns.microsoft.com
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:2.0.1) Gecko/20100101 Firefox/4.0.1
Accept text/html, /
Accept-Language en-us,en;q=0.5
Accept-Encoding gzip, deflate
Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive 115
Connection keep-alive
Content-Type application/x-www-form-urlencoded; charset=UTF-8
X-Requested-With XMLHttpRequest
Referer https://pqompo2test01.dns.microsoft.com/Incident/List
Content-Length 330
Cookie MC1=GUID=111c287d88c64447a63719bb2c858981&HASH=7d28&LV=20114&V=3; A=I&I=AxUFAAAAAACJCAAAMuSpPH1Citx6nZO0iHfvdA!!&CS=116|9n002j21b03; WT_FPC=id=131.107.0.73-1717525904.30146426:lv=1308581948698:ss=1308581948698; MUID=7F438FBFEEE948D88DA06B04F6923159; MSID=Microsoft.CreationDate=04/20/2011 16:45:49&Microsoft.LastVisitDate=06/20/2011 15:59:10&Microsoft.VisitStartDate=06/20/2011 15:59:10&Microsoft.CookieId=4c7552d0-5e75-4e5e-98b9-4ca52421a738&Microsoft.TokenId=ffffffff-ffff-ffff-ffff-ffffffffffff&Microsoft.NumberOfVisits=27&Microsoft.CookieFirstVisit=1&Microsoft.IdentityToken=AA==&Microsoft.MicrosoftId=0668-8044-9161-9043; ANON=A=FA4FB528F204DDFA69239A4FFFFFFFFF&E=b4d&W=4; NAP=V=1.1&E=af3&C=hJtCCJq27admlaiwmdzvTmnAwIEVXv1jFR2I2bJ-gncMGQOJce96RQ&W=4; mcI=Wed, 27 Apr 2011 16:48:43 GMT; omniID=fd752842_58d3_4833_9a0f_d0e1e3bbfef3; WT_NVR_RU=0=msdn:1=:2=; ASP.NET_SessionId=dbcqi222tehjorefcopchuzu; MS0=7fc23d65df4241c89554b502149ccc13; MICROSOFTSESSIONCOOKIE=Microsoft.CookieId=94c8a34f-9184-4e10-84c5-2b9c43c7a962&Microsoft.CreationDate=06/20/2011 15:59:10&Microsoft.LastVisitDate=06/20/2011 15:59:10&Microsoft.NumberOfVisits=1&SessionCookie.Id=04DF98242DBD0730C9388487546F2F37; RPSMCA=FAAaARSsz90pZKmFSg5n0wbtR5MnQAldBwNmAAAEgAAACDNAEUimN1wb2AD%2Bp1PnEJUdd7n5VumQIQerCQYdD5IEd6ZCDEshkiTkvVl5a9eA6%2B9a0Os/1FpoqtvsGYMdWUUc98PUl5ZTo%2BFXAqxiZ9BL5D69OLCPsZEXitrZMulmKXFGQiAD5FqJY8JOOSJ1xptRwdkdrxGF8PuNit/Si87Ft7g4sF9vE878lMSx6TSmQq3nrurnBbdbUvDvwTKLoY0gAikOxJ7GmZoLw4kbzaLR/6/a/XSJFv%2BZ6uHsIwkMn6mndoZKfg3LLjDlCpozrHBlnKtgkn7yZXtd8Or420IXuPMUAF3gfp8VAkhKlVceTXpBv2h4gs6g; RPSMCSA=FAAaARSsz90pZKmFSg5n0wbtR5MnQAldBwNmAAAEgAAACEdSXDQ0SIKI2AC/tM6y7CeHdaKVAab/n/4TLKkF5/01jGkXR0vA07MTvS5vhwgjCPMs4zke%2B0jnB1DqOV2vI4VqQ/%2BOIYh52QkaLREoD5L718AjEJOQdDVRRZiIB51CiYtS0P/kgIkEtfDa5yuTr3w6V2IKhy2%2B6wVrP/UqxsJR%2BZ1QmGxtjv7eQVGdIndrkPx5e9wFqj1qEcf9FNfH0/uajuaTFaNmi/3dQfWuEKxGpoHWNxgoMf8PHLVi2hqltqK47OloCGqQGLPQPx0PSg1K73FTZHhl3%2BuxyNqyWJumKsAUAGuMUzFhTPsQ7JdOSfY2SYyHeaZP; RPSShare=1; MSPAuth=1NNm8kdmWAFrAuL2d8qOShxJKehL!CxEkCQvsgPdNGDqo0XFGsreQZ9GMVjiT1*bHPlGcNVsyfbVO7h!eY32bCNY7Farp2grIyEgAFv7YgJqWZN2Q87*LBZnZ0ASWmhPqe; MSPProf=1ZN*xhGN9GRXSO*HEmrISYo6cowSUbmxtIsYfqtHv!!VzEybb1I33*BdWWJrz54tkO5BzS3eTprAXL1LO9ELLBziO8Sm8WTzkSbV*E6ECcX9N92*AFiJztc4rlwCLQnMBhxlV0qzvlRN4dS1SajyzABZDNBTG*tdyqfnuP6jkSevAhuXYvnEuKZQKAF5fvgr4!oiBQ2KhnuH0$; RequestVerificationToken_Lw=TOS6XUQ+17bDOxh2T75NhhFy2KIJP5BP9MetB7cAa4i68ZEHIEpgE7xwQhzid/YiZCm4GsbW2zsJjlIxkB1hrhVGoU++E1I5BP9X2PyKn0O8tic84cWNz8QRjLDcaAcF4iYEQQ==; prmrsdninc=1
When I run locally on my Win7 machine I simply get the text back that I am expecting.
I was having the same problem trying to return 500 pages containing only text for processing by telerik controls. Of course it worked tickity-boo on my development machine and failed when published up to the proper IIS servers.
This fixed it for me:
http://blog.janjonas.net/2011-04-13/asp_net-prevent-iis_75_overriding-custom-error-page-iis-default-error-page
Summary: Type putting a
Response.TrySkipIisCustomErrors = true;
line in your action