Search Results

Search found 1130 results on 46 pages for 'encode'.

Page 27/46 | < Previous Page | 23 24 25 26 27 28 29 30 31 32 33 34  | Next Page >

  • How to render plain HTML links in Asp.Net MVC loop?

    - by Joannes Vermorel
    I would like to render a list of HTML links in ASP.NET MVC. Note that the links are absolute and external to the website being designed. The following code works: <% foreach (var item in Model) { %> <tr> <td> <%= Html.Encode(item.Id) %> </td> <td> <%= String.Format("<a href=\"{0}\">link</a>", item.Url) %> </td> </tr> <% } %> But I am wondering if it's really the right approach. Am I missing some obvious MVC control here?

    Read the article

  • Allowing asterisk in URL - ASP.NET MVC 2 - .NET 4.0 or encoding

    - by raRaRa
    I'm having a trouble allowing asterisk (*) in the URL of my website. I am running ASP.NET MVC 2 and .NET 4.0. Here's an example that describes the problem: http://mysite.com/profile/view/Nice* The username is Nice* and ASP.NET says there are illegal characters in the URL: Illegal characters in path. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.ArgumentException: Illegal characters in path. I have tried all the Web.config methods I've seen online such as: <pages validateRequest="false"> and <httpRuntime requestPathInvalidCharacters="" requestValidationMode="2.0" /> So my question is: Is it possible to allow asterisk in URL? If not, is there some encoding method in .NET that can encode asterisk(*) ? Thanks!

    Read the article

  • GetAllUsers - MVC

    - by Jemes
    I’m using the Membership Provider and would like to display a list of all the users and their First Name, Last Name etc using the GetAllUsers function. I'm having trouble understanding how to implement this function in MVC. Has anyone implemented this in MVC or is there an easier way to list all the users in my application? Any help or advise would be really helpful. Controller public ActionResult GetUsers() { var users = Membership.GetAllUsers(); return View(users); } View Model public class GetUsers { [Required] [DisplayName("User name")] public string UserName { get; set; } [Required] [DisplayName("User name")] public string FirstName { get; set; } } View <%= Html.Encode(item.UserName) %> Error The model item passed into the dictionary is of type 'System.Web.Security.MembershipUserCollection', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable`1[Account.Models.GetUsers]'.

    Read the article

  • Issue with WIC image resizing on ASP.NET MVC 2

    - by Dave
    I am attempting to implement image resizing on user uploads in ASP.NET MVC 2 using a version of the method found: here on asp.net. This works great on my dev machine, but as soon as I put it on my production machine, I start getting the error 'Exception from HRESULT: 0x88982F60' which is supposed to mean that there is an issue decoding the image. However, when I use WICExplorer to open the image, it looks ok. I've also tried this with dozens of images of various sources and still get the error (though possible, I doubt all of them are corrupted). Here is the relevant code (with my debugging statements in there): MVC Controller [Authorize, HttpPost] public ActionResult Upload(string file) { //Check file extension string fx = file.Substring(file.LastIndexOf('.')).ToLowerInvariant(); string key; if (ConfigurationManager.AppSettings["ImageExtensions"].Contains(fx)) { key = Guid.NewGuid().ToString() + fx; } else { return Json("extension not found"); } //Check file size if (Request.ContentLength <= Convert.ToInt32(ConfigurationManager.AppSettings["MinImageSize"]) || Request.ContentLength >= Convert.ToInt32(ConfigurationManager.AppSettings["MaxImageSize"])) { return Json("content length out of bounds: " + Request.ContentLength); } ImageResizerResult irr, irr2; //Check if this image is coming from FF, Chrome or Safari (XHR) HttpPostedFileBase hpf = null; if (Request.Files.Count <= 0) { //Scale and encode image and thumbnail irr = ImageResizer.CreateMaxSizeImage(Request.InputStream); irr2 = ImageResizer.CreateThumbnail(Request.InputStream); } //Or IE else { hpf = Request.Files[0] as HttpPostedFileBase; if (hpf.ContentLength == 0) return Json("hpf.length = 0"); //Scale and encode image and thumbnail irr = ImageResizer.CreateMaxSizeImage(hpf.InputStream); irr2 = ImageResizer.CreateThumbnail(hpf.InputStream); } //Check if image and thumbnail encoded and scaled correctly if (irr == null || irr.output == null || irr2 == null || irr2.output == null) { if (irr != null && irr.output != null) irr.output.Dispose(); if (irr2 != null && irr2.output != null) irr2.output.Dispose(); if(irr == null) return Json("irr null"); if (irr2 == null) return Json("irr2 null"); if (irr.output == null) return Json("irr.output null. irr.error = " + irr.error); if (irr2.output == null) return Json("irr2.output null. irr2.error = " + irr2.error); } if (irr.output.Length > Convert.ToInt32(ConfigurationManager.AppSettings["MaxImageSize"]) || irr2.output.Length > Convert.ToInt32(ConfigurationManager.AppSettings["MaxImageSize"])) { if(irr.output.Length > Convert.ToInt32(ConfigurationManager.AppSettings["MaxImageSize"])) return Json("irr.output.Length > maximage size. irr.output.Length = " + irr.output.Length + ", irr.error = " + irr.error); return Json("irr2.output.Length > maximage size. irr2.output.Length = " + irr2.output.Length + ", irr2.error = " + irr2.error); } //Store scaled and encoded image and thumbnail .... return Json("success"); } The code is always failing when checking if the output stream is null (i.e. irr.output == null is true). ImageResizerResult and ImageResizer public class ImageResizerResult : IDisposable { public MemoryIStream output; public int width; public int height; public string error; public void Dispose() { output.Dispose(); } } public static class ImageResizer { private static Object thislock = new Object(); public static ImageResizerResult CreateMaxSizeImage(Stream input) { uint maxSize = Convert.ToUInt32(ConfigurationManager.AppSettings["MaxImageDimension"]); try { lock (thislock) { // Read the source image var photo = ByteArrayFromStream(input); var factory = (IWICComponentFactory)new WICImagingFactory(); var inputStream = factory.CreateStream(); inputStream.InitializeFromMemory(photo, (uint)photo.Length); var decoder = factory.CreateDecoderFromStream(inputStream, null, WICDecodeOptions.WICDecodeMetadataCacheOnDemand); var frame = decoder.GetFrame(0); // Compute target size uint width, height, outWidth, outHeight; frame.GetSize(out width, out height); if (width > height) { //Check if width is greater than maxSize if (width > maxSize) { outWidth = maxSize; outHeight = height * maxSize / width; } //Width is less than maxSize, so use existing dimensions else { outWidth = width; outHeight = height; } } else { //Check if height is greater than maxSize if (height > maxSize) { outWidth = width * maxSize / height; outHeight = maxSize; } //Height is less than maxSize, so use existing dimensions else { outWidth = width; outHeight = height; } } // Prepare output stream to cache file var outputStream = new MemoryIStream(); // Prepare JPG encoder var encoder = factory.CreateEncoder(Consts.GUID_ContainerFormatJpeg, null); encoder.Initialize(outputStream, WICBitmapEncoderCacheOption.WICBitmapEncoderNoCache); // Prepare output frame IWICBitmapFrameEncode outputFrame; var arg = new IPropertyBag2[1]; encoder.CreateNewFrame(out outputFrame, arg); var propBag = arg[0]; var propertyBagOption = new PROPBAG2[1]; propertyBagOption[0].pstrName = "ImageQuality"; propBag.Write(1, propertyBagOption, new object[] { 0.85F }); outputFrame.Initialize(propBag); outputFrame.SetResolution(96, 96); outputFrame.SetSize(outWidth, outHeight); // Prepare scaler var scaler = factory.CreateBitmapScaler(); scaler.Initialize(frame, outWidth, outHeight, WICBitmapInterpolationMode.WICBitmapInterpolationModeFant); // Write the scaled source to the output frame outputFrame.WriteSource(scaler, new WICRect { X = 0, Y = 0, Width = (int)outWidth, Height = (int)outHeight }); outputFrame.Commit(); encoder.Commit(); return new ImageResizerResult { output = outputStream, height = (int)outHeight, width = (int)outWidth }; } } catch (Exception e) { return new ImageResizerResult { error = "Create maxsizeimage = " + e.Message }; } } } Thoughts on where this is going wrong? Thanks in advance for the effort.

    Read the article

  • URLEncoding a string with Objective-C

    - by Chris
    I'm trying to URL encode a string to form a GET request from objective-c. NSString *params = @"'Decoded data!'/foo.bar:baz"; NSRunAlertPanel( @"Error", [params urlEncoded], @"OK", nil, nil ); This is the category extending NSString -(NSString *) urlEncoded { NSString *encoded = (NSString *)CFURLCreateStringByAddingPercentEscapes( NULL, (CFStringRef)self, NULL, (CFStringRef)@"!*'\"();:@&=+$,/?%#[]% ", kCFStringEncodingUTF8 ); return encoded; } So the first time I run it I get back 1606410046ecoded 1606410784ata2270.000000foo.bar0X1.001716P-1042baz from the dialog box. Immediately after I run it again I get this 1606410046ecoded 1606410944ata227369374562920703448982951250259562309742470533728899744288431318481119278377104028261651081181287077973859930826299575521579020410425419424562236383226511593137467590082636817579938932512039895040.000000foo.bar0X1.66E6156303225P+771baz Then if I run it AGAIN it goes back to the first one. It's really weird. If params is set to @"&" or @" " I just get back a "2" (w/o the quotes) in the dialog box. Also is there a way I can have the % signs be shown in the alert dialog? Thanks

    Read the article

  • retreive POST data from FLASH to ASP.Net

    - by Martin Ongtangco
    here's my AS3 code: var jpgEncoder:JPGEncoder = new JPGEncoder(100); var jpgStream:ByteArray = jpgEncoder.encode(bitmapData); var header:URLRequestHeader = new URLRequestHeader("Content-type", "application/octet-stream"); var jpgURLRequest:URLRequest = new URLRequest("/patients/webcam.aspx"); jpgURLRequest.requestHeaders.push(header); jpgURLRequest.method = URLRequestMethod.POST; jpgURLRequest.data = jpgStream; navigateToURL(jpgURLRequest, "_self"); And here's my ASP.Net Code try { string pt = Path.Combine(PathFolder, "test.jpg"); HttpFileCollection fileCol = Request.Files; Response.Write(fileCol.Count.ToString()); foreach (HttpPostedFile hpf in fileCol) { hpf.SaveAs(pt); } } catch (Exception ex) { Response.Write(ex.Message); } im getting a weird error, HttpFox mentioned: "NS_ERROR_NET_RESET" Any help would be excellent! Thanks!

    Read the article

  • Skype Raw API (NOT COM API) send message problem

    - by Mike Trader
    In converting this CONSOLE example to a full windows dialog implementation I have run into a very "simple problem". SendMessage() (line 283) is returning zero, GetLastError reveals 0x578 - Invalid window handle. http://read.pudn.com/downloads51/sourcecode/windows/multimedia/175678/msgapitest.cpp__.htm (https://developer.skype.com/Download/Sample...example_win.zip) C++ 2005 Studio express edition instructions http://forum.skype.com/index.php?showtopic=54549 The previous call using HWND_BROADCAST works and Skype replies as expected, so I know Skype is installed and working properly. The handle I use is the wParam value from the Skype Reply message, as in the code. This is non zero, but I am not sure if there is a way to test it other than with SendMessage. The compiled app from this C++ code example (see zip download) does actually work so I am stumped. I do encode the message with UTF8, and I create an instance of the COPYDATASTRUCT in my app, populate it then call SendMessage() with the COPYDATASTRUCT pointer in lparam. Skype does not respond nor does it obey. Am I missing something obvious here?

    Read the article

  • Adding audio channel using ffmpeg

    - by Raj
    Hi all, I am working on ffmpeg and trying to add a audio stream on the fly. I am using AudioQueues and I get raw audio buffer. I am encoding audio with linear PCM and hence the audio I get will be of raw format, which I know ffmpeg does accept it. But I cannot figure out how. I have looked into AVStream, where in we have to create a new stream for this audio channel but how do I encode it to a video which is already initialized in another AVStream structure. Overall, I would like to have an idea of the architecture of ffmpeg. I found it difficult to work since it is least documented. Any pointers or details are appreciated. Thanks and Regards, Raj Pawan G

    Read the article

  • PHP / SimpleXML - Why does Simplexml_load_string() fail to parse Google Weather API xml in Chinese (

    - by John Himmelman
    I'm trying to load parse a Google Weather API response (chinese response). Here is the API call.. http://www.google.com/ig/api?weather=11791&hl=zh-CN // This code fails with the following error $xml = simplexml_load_file('http://www.google.com/ig/api?weather=11791&hl=zh-CN'); ( ! ) Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 1: parser error : Input is not proper UTF-8, indicate encoding ! Bytes: 0xB6 0xE0 0xD4 0xC6 in C:\htdocs\weather.php on line 11 Why does loading this response fail? How do I encode/decode the response so that simplexml loads it properly?

    Read the article

  • Need help with basic ASM

    - by Malfist
    Hello, I'm trying to convert some c code to assmebly, and I need some help. char encode(char plain){ __asm{ mov eax, plain add eax, 2 ret } //C code /* char code; code = plain+2; return code;*/ } First problem is that visual studio complains that the register size doesn't match, i.e. eax is too small/large for char. I was under the impression that they were both DWORDs. Also, if I leave the variable in eax, and ret in assembly, it'll actually return that variable, right?

    Read the article

  • Compact representation of GUID/UUID?

    - by chakrit
    I need to generate a GUID and save it via a string representation. The string representation should be as short as possible as it will be used as part of an already-long URL string. Right now, instead of using the normal abcd-efgh-... representation, I use the raw bytes generated and base64-encode them instead, which results in a somewhat shorter string. But is it possible to make it even shorter? I'm OK with losing some degree of uniqueness and keeping a counter, but scanning all existing keys is not an option. Suggestions?

    Read the article

  • mvc presentation model best-practices

    - by Andrew Florko
    Hello, everybody How do you usually convert business objects to presentation? For example: Business object Person { Id, FirstName, LastName, Patronymic ... } should be presented as "LastName F. P. " in html layout. We use Presentation classes hierarchy to represent data ready for output from Business model. Questions: Will you keep presentation model completely separated from Business Model. For example, can strong-typed views (MVC ASP.NET) aggregate formatted business data as well as raw business objects (that leads toward <%=Html.Encode(PersonHelper.ToShort(Model.Person))% html layout injections) What architecture layer do you choose for conversion (mvc controllers that formats business data from business layer, for instance). Thank you in advance

    Read the article

  • Data structure for Settlers of Catan map?

    - by templatetypedef
    Hello all- A while back someone asked me if I knew of a nice way to encode the information for the game Settlers of Catan. This would require storing a hexagonal grid in a way where each hex can have data associated with it. More importantly, though, I would need some way of efficiently looking up vertices and edges on the sides of these hexagons, since that's where all the action is. My question is this: is there a good, simple data structure for storing a hexagonal grid while allowing for fast lookup of hexagons, edges between hexagons, and vertices at the intersections of hexagons? I know that general structures like a winged-edge or quad-edge could do this, but that seems like massive overkill. Thanks!

    Read the article

  • Specifying culture for http request/reponse

    - by Akash
    I have a ReSTful web service which needs to parse culture-sensitive data from the request. This data could either be in an XML body or part of the query string. Is there any acepted way of determining which culture the data is being sent in (and by extension the culture in which the response should be sent)? One option is simply to specify to the clients the culture in which all requests should be sent. A friendlier option seems to be to allow the client to specify the culture. I've considered: a) using the accept-language http header to encode this information. b) using the xml:lang attribute for XML POSTs, and an extra field for query strings (e.g. ...&culture=en-GB) http://www.w3.org/International/questions/qa-accept-lang-locales warns of limitations in using the accept-language header, but most of the warnings seem to center around requests originating from browsers. In my case the requests will come from other applications. All advice greatly appreciated!

    Read the article

  • Use HttpGet with illegal characters in the URL

    - by kaciula
    I am trying to use DefaultHttpClient and HttpGet to make a request to a web service. Unfortunately the web service URL contains illegal characters such as { (ex: domain.com/service/{username}). It's obvious that the web service naming isn't well written but I can't change it. When I do HttpGet(url), I get that I have an illegal character in the url (that is { and }). If I encode the URL before that, there is no error but the request goes to a different URL where there is nothing. The url, although has illegal characters, works from the browser but the HttpGet implementation doesn't let me use it. What should I do or use instead to avoid this problem?

    Read the article

  • cakePHP paginate with post data without sessions, serialization or post to get

    - by openprojdevel
    I have created a small search and filter form method post in controller/index, which posts to it self the conditions and fields to paginate ( $this-paginate($conditions) ) However that is good for the first page, the subsequent pages the filer conditions are lost. pagination passArgs supports get variables well. Is there an un complex way to pass the post conditions to the other paginated pages? The method I have looked at is pass the $conditions in session , which isnt without complexity of assigning session and unset the session on submitting the form again (more refinements to the filter criteria by the user ) The other method is passing the $conditions as serialized string url_encode as an get parameter. Is there an good cake way to do this more like passArgs, sessions and url encode do not look like cake style. Thanks

    Read the article

  • Python: Getting INVALID response from PayPal's Sandbox IPN, slowly going insane...

    - by thepeanut
    Hi All I am trying to implement a simple online payment system using PayPal, however I have tried everything I know and am still getting an INVALID response. I know it's nothing too simple, because I get a VERIFIED response when using the IPN simulator. I have tried putting the items into a dict first, I have tried fixing the encoding, and still nothing. PayPal says the reasons for an INVALID response could be: Sending wrong items or in wrong order (pretty sure it's not this) Sending to the wrong address (definitely not this) Encoding items incorrectly (I dont think it's this, set encoding to UTF-8 on both paypal and my script) The following is the snippet concerned: f = cgi.FieldStorage() newparams = 'cmd=_notify-validate' for key in f.keys(): val = f[key].value newparams += '&' + urlencode({key: val.encode('utf-8')}) req = urllib2.Request(PP_URL, newparams) req.add_header("Content-type", "application/x-www-form-urlencoded") http = urllib2.urlopen(req) ret = http.read() fi.write(ret + '\n') if ret == 'VERIFIED': #*do stuff* Can anyone suggest anything I can do to fix this?! Cheers Sam

    Read the article

  • Extracting information from PDFs of research papers

    - by Christopher Gutteridge
    I need a mechanism for extracting bibliographic metadata from PDF documents, to save people entering it by hand or cut-and-pasting it. At the very least, the title and abstract. The list of authors and their affiliations would be good. Extracting out the references would be amazing. Ideally this would be an open source solution. The problem is that not all PDF's encode the text, and many which do fail to preserve the logical order of the text, so just doing pdf2text gives you line 1 of column 1, line 1 of column 2, line 2 of column 1 etc. I know there's a lot of libraries. It's identifying the abstract, title authors etc. on the document that I need to solve. This is never going to be possible every time, but 80% would save a lot of human effort.

    Read the article

  • How to avoid encoding the key of request parameters being encoding

    - by fxp
    I'm trying to send a http request using WS.url() with a action receive a custom class parameter like public static void add(@Valid MyPage info) {...} There is a Map in MyPage @Required public Map<String, String> content = new HashMap<String, String>(); But When I try to send a request with WS.url().setParameter("info.content[name]","mynameis"); The action got no parameter and request's querystring convert info.content[name] into ...%5Bname%5D... I checked the WS.createQueryString and found it will encode all key and value. Any way to avoid that?

    Read the article

  • URL encoding for latin characters in Java

    - by sammichy
    I'm trying to read in an image URL. As mentioned in the java documentation, I tried converting the URL to URI by String imageURL = "http://www.shefinds.com/files/Christian-Louboutin-Décolleté-100-pumps.jpg"; URL url = new URL(imageURL); url = new URI(url.getProtocol(), url.getHost(), url.getFile(), null).toURL(); URLConnection conn = url.openConnection(); InputStream is = conn.getInputStream(); I get the following error when the code is executed http://www.shefinds.com/files/Christian-Louboutin-Décolleté-100-pumps.jpg What am I doing wrong and what is the right way to encode this URL?

    Read the article

  • GWT and Panda Video Converter

    - by Maksim
    I'm writing GWT application where I need to upload video file and encode that video into different video formats. I've decided to use Panda Video Converter. I was able to run panda on my EC2 instance (using their image) and I can upload video from Panda's test pages but now I'm trying to make same thing with my own application in GWT. The question that I have is: How do I get Video id and how do I post my video to the server. What URL do I need to use for that? I tried to read their documentation but have no clue where to start. This is my fist time working with webservices and url, probably that's why I don't how it works.

    Read the article

  • How to read a csv file with python

    - by john
    Hello, I'm trying to read a csv file but it doesn't work. I can read my csv file but when I see what I read, there where white space between values. Here is my code # -*- coding: iso-8859-1 -*- import sql_db, tmpl_macros, os import security, form, common import csv class windows_dialect(csv.Dialect): """Describe the usual properties of unix-generated CSV files.""" delimiter = ',' quotechar = '"' doublequote = 1 skipinitialspace = 0 lineterminator = 'n' quoting = csv.QUOTE_MINIMAL def reco(d): cars = {210:'"', 211:'"', 213:"'", 136:'à', 143:'è', 142:'é'} for c in cars: d = d.replace(chr(c),cars[c]) return d def page_process(ctx): if ctx.req_equals('catalog_send'): if 'catalog_file' in ctx.locals.__dict__: contenu = ctx.locals.catalog_file[0].file.read() #contenu.encode('') p = csv.reader(contenu, delimiter=',') inserted = 0 modified = 0 (cr,db) = sql_db.cursor_get() for line in p: if line: logfile = open('/tmp/test.log', 'a') logfile.write(line[0]) logfile.write('\n') logfile.write('-----------------------------\n') logfile.close()

    Read the article

  • How does MTOM work + sample code

    - by zengr
    I am trying to make a very simple web-service which does the following: The client hits the web service requesting a file. The web service's service class queries a hashtable which has the key (search query) and the value as the base64encoded value of a file (say a pdf) Now,I need to use MTOM to return the base64encoded value stored in the hashtable to the client. It's upto the client to decode it and convert it to pdf. So, here are my questions: I understand we encode files to base64 for transmission via web service, but where and how does MTOM come into the picture there? Can some one provide me a simple method which uses MTOM and sends the data back. Do we need to specify something in the WSDL too? or a simple String return type would suffice? Why/Why not? Thanks I have seen this code. It uses a lot of annotations, I just need a simple java code using MTOM. New to J2EE HERE :)

    Read the article

  • How can I copy files with names containing spaces and UNICODE, when using a shell script?

    - by LOlliffe
    I have a list of files that I'm trying to copy and move (using cp and mv) in a bash shell script. The problem that I'm running into, is that I can't get either command to recognize a huge number of files, seemingly because the filenames contain spaces and/or unicode characters. I couldn't find any switches to decode/re-encode these characters. Instead, for example, if I copy "file name.xml", I get "*.xml" and a script error that the file wasn't found for my result. Does anyone know settings or commands that will deal with these files?

    Read the article

  • Variable-byte encoding clarification

    - by Myx
    Hello: I am very new to the world of byte encoding so please excuse me (and by all means, correct me) if I am using/expressing simple concepts in the wrong way. I am trying to understand variable-byte encoding. I have read the Wikipedia article (http://en.wikipedia.org/wiki/Variable-width_encoding) as well as a book chapter from an Information Retrieval textbook. I think I understand how to encode a decimal integer. For example, if I wanted to provide variable-byte encoding for the integer 60, I would have the following result: 1 0 1 1 1 1 0 0 (please let me know if the above is incorrect). If I understand the scheme, then I'm not completely sure how the information is compressed. Is it because usually we would use 32 bits to represent an integer, so that representing 60 would result in 1 1 1 1 0 0 preceded by 26 zeros, thus wasting that space as opposed to representing it with just 8 bits instead? Thank you in advance for the clarifications.

    Read the article

< Previous Page | 23 24 25 26 27 28 29 30 31 32 33 34  | Next Page >