Tumgik
jaredchu · 2 years
Text
How do you create a dropdownlist from an enum in ASP.NET MVC?
How do you create a dropdownlist from an enum in ASP.NET MVC?
I’m trying to use the Html.DropDownList extension method but can’t figure out how to use it with an enumeration. Let’s say I have an enumeration like this: public enum ItemTypes { Movie = 1, Game = 2, Book = 3 } How do I go about creating a dropdown with these values using the Html.DropDownList extension method? Or is my best bet to simply create a for loop and create the Html elements…
Tumblr media
View On WordPress
4 notes · View notes
jaredchu · 2 years
Text
ASP.NET Web API – PUT & DELETE Verbs Not Allowed – IIS 8
ASP.NET Web API – PUT & DELETE Verbs Not Allowed – IIS 8
I recently upgraded from Visual Studio 2010 to the Visual Studio 2012 RC. The installer also installs IIS 8 Express which Visual Studio now uses as the default web server. IIS 8 is blocking my WEB API requests that use PUT AND DELETE verbs. IIS returns a 405 error, The requested resource does not support http method 'PUT'. I know people have issues with this in the past and there are several…
Tumblr media
View On WordPress
4 notes · View notes
jaredchu · 2 years
Text
Why does the CheckBoxFor render an additional input tag, and how can I get the value using the FormCollection?
Why does the CheckBoxFor render an additional input tag, and how can I get the value using the FormCollection?
In my ASP.NET MVC app, I am rendering a checkbox using the following code: <%= Html.CheckBoxFor(i=>i.ReceiveRSVPNotifications) %> Now, I see that this renders both the checkbox input tag and a hidden input tag. The problem that I am having is when I try retrieve the value from the checkbox using the FormCollection: FormValues["ReceiveRSVPNotifications"] I get the value “true,false”. When…
View On WordPress
2 notes · View notes
jaredchu · 2 years
Text
ASP.NET dynamically created controls and Postback
ASP.NET dynamically created controls and Postback
I know this question has been asked thousands of times, and I’ve struggled with it before, but for some reason, I can’t accomplish what I want to accomplish… I have a dynamically added LinkButton that when clicked will dynamically add a control (in this example, a textbox) to the same panel. The intent is to continuously add on as many controls as times the LinkButton was clicked (i.e. I click it…
View On WordPress
0 notes
jaredchu · 2 years
Text
How to get a user's client IP address in ASP.NET?
How to get a user’s client IP address in ASP.NET?
We have Request.UserHostAddress to get the IP address in ASP.NET, but this is usually the user’s ISP’s IP address, not exactly the user’s machine IP address who for example clicked a link. How can I get the real IP Address? For example, in a Stack Overflow user profile it is: “Last account activity: 4 hours ago from 86.123.127.8”, but my machine IP address is a bit different. How does Stack…
Tumblr media
View On WordPress
0 notes
jaredchu · 2 years
Text
Content-Disposition:What are the differences between "inline" and "attachment"?
Content-Disposition:What are the differences between “inline” and “attachment”?
What are the differences between Response.AddHeader("Content-Disposition", "attachment;filename=somefile.ext") and Response.AddHeader("Content-Disposition", "inline;filename=somefile.ext") I don’t know the differences , because when I use one or another I always get a window prompt asking me to download the file for both of them. I read the specs, but it is clueless. Answers: Thank you for…
View On WordPress
0 notes
jaredchu · 2 years
Text
Disable browser cache for entire ASP.NET website
Disable browser cache for entire ASP.NET website
I am looking for a method to disable the browser cache for an entire ASP.NET MVC Website I found the following method: Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache); Response.Cache.SetNoStore(); And also a meta tag method (it won’t work for me, since some MVC actions send partial HTML/JSON through Ajax, without a head, meta tag). <meta http-equiv="PRAGMA"…
Tumblr media
View On WordPress
0 notes
jaredchu · 2 years
Text
asp.net – session – multiple browser tabs – different sessions?
asp.net – session – multiple browser tabs – different sessions?
I’d like to maintain a session state per browser tab. Is this easy (or even possible) to do in ASP.NET? Example: A user hits Ctrl-T in firefox 5 times and visits the site in each tab. I’d like each tab to have its own session state on the server Answers: Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please…
View On WordPress
0 notes
jaredchu · 2 years
Text
How to launch an EXE from Web page (asp.net)
How to launch an EXE from Web page (asp.net)
This is an internal web application where we would like the Web pages to contain links to several utilities that are Win32 EXE. The EXEs are trusted and produced by us. (don’t care if it asks if its ok to Run or Save). I tried direct link (e.g. C:notepad.exe) which works locally only. (This will be a share on the network). Tried File:/// and did not work. IE7 is the browser needed. Answers: Thank…
View On WordPress
0 notes
jaredchu · 2 years
Text
How do I create a custom membership provider for ASP.NET MVC 2?
How do I create a custom membership provider for ASP.NET MVC 2?
How do I create a custom membership for ASP.NET MVC 2 based on the ASP.NET membership provider? Answers: Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible. Method 1 I have created a…
View On WordPress
0 notes
jaredchu · 2 years
Text
Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. The statement has been terminated
Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. The statement has been terminated
I have many users on my web site (20000-60000 per day), which is a download site for mobile files. I have remote access to my server (windows server 2008-R2). I’ve received “Server is unavailable” errors before, but am now seeing a connection timeout error. I’m not familiar with this – why does it occur and how can I fix it? The full error is below: Server Error in ‘/’ Application. Timeout…
View On WordPress
0 notes
jaredchu · 2 years
Text
Import and Export Excel – What is the best library?
Import and Export Excel – What is the best library?
In one of our ASP.NET applications in C#, we take a certain data collection (SubSonic collection) and export it to Excel. We also want to import Excel files in a specific format. I’m looking for a library I can use for this purpose. Requirements: Excel 2007 files (Does Excel 2003 support over 64k rows? I need more than that.) Does not require Excel on the server Takes a typed collection and, if…
View On WordPress
0 notes
jaredchu · 2 years
Text
ASP.NET Identity's default Password Hasher – How does it work and is it secure?
ASP.NET Identity’s default Password Hasher – How does it work and is it secure?
I am wondering wether the Password Hasher that is default implemented in the UserManager that comes with MVC 5 and ASP.NET Identity Framework, is secure enough? And if so, if you could explain to me how it works? IPasswordHasher interface looks like this: public interface IPasswordHasher { string HashPassword(string password); PasswordVerificationResult VerifyHashedPassword(string…
View On WordPress
0 notes
jaredchu · 2 years
Text
How to use non-thread-safe async/await APIs and patterns with ASP.NET Web API?
How to use non-thread-safe async/await APIs and patterns with ASP.NET Web API?
This question has been triggered by EF Data Context – Async/Await & Multithreading. I’ve answered that one, but haven’t provided any ultimate solution. The original problem is that there are a lot of useful .NET APIs out there (like Microsoft Entity Framework’s DbContext), which provide asynchronous methods designed to be used with await, yet they are documented as not thread-safe. That makes…
View On WordPress
0 notes
jaredchu · 2 years
Text
What is the App_Data folder used for in Visual Studio?
What is the App_Data folder used for in Visual Studio?
When creating a new ASP.NET application in Visual Studio, a couple of files and folders are created automatically. One of those folders is called App_Data. Also when publishing a website by selecting the menu option Build->Publish a checkbox is available Include files from the App_Data folder. Am I right assuming that the files put in this file and its sub-folders are not going to be accessible…
View On WordPress
0 notes
jaredchu · 2 years
Text
Using VirtualPathProvider to load ASP.NET MVC views from DLLs
Using VirtualPathProvider to load ASP.NET MVC views from DLLs
Based on this question here and using code found here I’m trying to load views that are embedded resources in a separate DLL project, and the original question’s author says he has had success doing this – but I can’t get it to work as it seems the MVC view engine is intercepting the request and still looking at the file system for the view. Exception: Server Error in '/' Application. The view…
View On WordPress
0 notes
jaredchu · 2 years
Text
Why Response.Redirect causes System.Threading.ThreadAbortException?
When I use Response.Redirect(…) to redirect my form to a new page I get the error: A first chance exception of type ‘System.Threading.ThreadAbortException’ occurred in mscorlib.dll An exception of type ‘System.Threading.ThreadAbortException’ occurred in mscorlib.dll but was not handled in user code My understanding of this is that the error is being caused by the webserver aborting the…
View On WordPress
0 notes