asp.net-webpages

Trying to get SELECT SCOPE_IDENTITY() as c# variable

断了今生、忘了曾经 提交于 2020-03-03 07:47:07
问题 I am inserting a row into one table then want to get that new ID so I can add it in another variable where I have email address stored. var db = Database.Open("myDB"); var insertCommand1 = "INSERT INTO myDB (FirstName, LastName) Values(@0, @1)"; db.Execute(insertCommand1, first, last); var lastInsertedId = db.QueryValue("SELECT SCOPE_IDENTITY()"); var insertCommand2 = "INSERT INTO email (id_person, email) Values(@0, @1)"; db.Execute(insertCommand2, lastInsertId, email); where id_person is the

How can I sort my string array from .GetFiles() in order of date last modified in asp.net-webpages?

二次信任 提交于 2020-02-28 10:53:25
问题 I have seen a really close example here: Sorting Files by date But I am new to LINQ and couldn't get it to work (not sure I understand the DirectoryInfo or FileInfo classes). Here are the necessary code snippets: (When assigning the array): string[] files = Directory.GetFiles(Server.MapPath("~/User_Saves/" + WebSecurity.CurrentUserName), "*.xml"); for(int i = 0; i < files.Length; i++) { files[i] = files[i].Substring(files[i].LastIndexOf("\\") + 1); files[i] = files[i].Substring(0, files[i]

NullReferenceException in WebConfigScopeDictionary

▼魔方 西西 提交于 2020-01-11 10:01:55
问题 Occasionally (about once a month) an ASP.NET MVC 3 web application fails with this exception. System.NullReferenceException: Object reference not set to an instance of an object. Server stack trace: at System.Collections.Specialized.NameObjectCollectionBase.BaseGetAllKeys() at System.Collections.Specialized.NameValueCollection.get_AllKeys() at System.Web.WebPages.Scope.WebConfigScopeDictionary.<>c__DisplayClass4.<.ctor>b__0() at System.Lazy`1.CreateValue() Exception rethrown at [0]: at System

Asp:FileUpload edit “No file selected” message

爱⌒轻易说出口 提交于 2019-12-30 03:32:06
问题 I just need to know if there's a way to change the message shown by the Asp:FileUpload when no file as been selected. Thanks. 回答1: You replace the text with your own message using CSS pseduo-class :after . You can declare a class like this one: .bar:after { content:"Please select a file"; background-color:white; } And assign it to your FileUpload control. The content message will replace the original one. Of course upon file selection you need to remove the message, you can do this for

WebMatrix ASP.NET Web Pages vs ASP.NET MVC 3

烂漫一生 提交于 2019-12-24 03:03:32
问题 I've looked at WebMatrix 2 and it seems simple and fun to play with. I play mainly with ASP.NET MVC 3 in C# with VS2010 Premium. I'd like to know what's the pros and cons of using ASP.NET Web Pages, against using ASP.NET MVC 3. And I'd like to know what's the pros and cons of WebMatrix too. Thanks! 回答1: Web Pages is a much lighter-weight development model than MVC. You would use it when testability and code separation is not needed - proof of concept stuff perhaps, or just a relatively simple

Disable Razors default .cshtml handler in a ASP.NET Web Application

我只是一个虾纸丫 提交于 2019-12-24 02:37:06
问题 Does anyone know how to disable the .cshtml extension completely from an ASP.NET Web Application? In essence I want to hijack the .cshtml extension and provide my own implementation based on a RazorEngine host, although when I try to access the page.cshtml directly it appears to be running under an existing WebPages razor host that I'm trying to disable. Note: it looks like its executing .cshtml pages under the System.Web.WebPages.Razor context as the Microsoft.Data Database is initialized. I

Can I use ASP.NET Web Pages without deploying the “bin” folder?

老子叫甜甜 提交于 2019-12-23 10:12:16
问题 I am creating a very simple site that was originally just a bunch of HTML / CSS files. Then I needed to add a little bit of server-side logic so I thought I'd use ASP.NET Web Pages as they sound like a suitable solution. So I changed index.html to index.cshtml , added the code I needed and I though that would be it (I also added this basic web.config file: <configuration> <system.web> <compilation debug="true" targetFramework="4.0" /> </system.web> </configuration> However, launching this on

Waiting on tasks in ASP.NET WebPages Razor view

笑着哭i 提交于 2019-12-23 04:54:09
问题 I am using async/await, and calling an async method from one of my views and I need to wait until it finishes. I've seen a lot of examples for ASP.NET MVC, where you can just put an "async" into the signature of your action. But I haven't seen any examples for ASP.NET WebPages. Do I just call "Wait()" on the returned task inside my Razor view? I've seen recommendations against Wait(). Please give me some references/examples on how to properly call async methods from within a Razor view in

Razor Host Factory error

a 夏天 提交于 2019-12-18 11:42:05
问题 I get a MvcWebRazorHostFactory error trying to run my app, but it's not an MVC app at all. I have the following web packages installed via nuget: Microsoft ASP.NET Razor Microsoft ASP.NET Web API 2.1 Microsoft ASP.NET Web Pages My app is angularjs front end using razor views (.cshtml). I don't understand why I keep getting this error. An exception of type 'System.InvalidOperationException' occurred in System.Web.WebPages.Razor.dll but was not handled in user code Additional information: Could

Make a “Web-Proxy” - Step By Step

心已入冬 提交于 2019-12-13 09:21:56
问题 Is there any way to show another page into your page? I cannot use frames, because frame will open that page directly, I want to copy the whole page and save it into new file, then show my new file to user. I think it is better to do this using a simple URL encryption because I don't like to show the real page address. For example, I want to use below URL instead of yahoo.com: www.myDomain.com/Open.aspx?url=zbipp_dpn ... I know how to read, encrypt and decrypt URL, but my problem is I don't