asp.net-mvc

Invalid zip file after creating it with System.IO.Compression

怎甘沉沦 提交于 2021-02-18 04:50:33
问题 I'm trying to create a zip file that contains one or more files. I'm using the .NET framework 4.5 and more specifically System.IO.Compression namespace. The objective is to allow a user to download a zip file through a ASP.NET MVC application. The zip file is being generated and sent to the client but when I try to open it by doing double click on it I get the following error: Windows cannot open the folder. The compressed (zipped) folder ... is invalid. Here's my code: [HttpGet] public

Invalid zip file after creating it with System.IO.Compression

南笙酒味 提交于 2021-02-18 04:42:45
问题 I'm trying to create a zip file that contains one or more files. I'm using the .NET framework 4.5 and more specifically System.IO.Compression namespace. The objective is to allow a user to download a zip file through a ASP.NET MVC application. The zip file is being generated and sent to the client but when I try to open it by doing double click on it I get the following error: Windows cannot open the folder. The compressed (zipped) folder ... is invalid. Here's my code: [HttpGet] public

Ajax POST to controller action to update view model, and then reload div

百般思念 提交于 2021-02-17 17:09:32
问题 I'm still shaky with my use of ajax so there are a couple holes in my implementation here. I am trying to post to a controller action that will call a stored procedure to update my view model and then reload the div that will display the information. Ajax Post: $("#order-summary-panel").click(function(){ $.ajax({ url: '@Url.Action("GetOrderSummary", "Home")', type: 'POST', success: function() { alert("It Worked!") } }); }); Controller Action: [HttpPost] public ActionResult GetOrderSummary {

Ajax POST to controller action to update view model, and then reload div

吃可爱长大的小学妹 提交于 2021-02-17 17:08:31
问题 I'm still shaky with my use of ajax so there are a couple holes in my implementation here. I am trying to post to a controller action that will call a stored procedure to update my view model and then reload the div that will display the information. Ajax Post: $("#order-summary-panel").click(function(){ $.ajax({ url: '@Url.Action("GetOrderSummary", "Home")', type: 'POST', success: function() { alert("It Worked!") } }); }); Controller Action: [HttpPost] public ActionResult GetOrderSummary {

How to upload and inject image to tinymce 4 using Asp.net MVC

北城余情 提交于 2021-02-17 13:59:03
问题 So because there is absolutely no modern way of uploading images to tinymce in .net for free , I was thinking of maybe adding a file upload input in html then upload it to server using ajax and then include the file in tinymce editor. The problem is injecting image to tinymce, I don't know how to... Is there any way? 回答1: Ok, Micro$oft or someone else needs to really do something about this, in the mean time here is the result of hours of debugging: This solution uses direct upload function

How to upload and inject image to tinymce 4 using Asp.net MVC

北战南征 提交于 2021-02-17 13:57:12
问题 So because there is absolutely no modern way of uploading images to tinymce in .net for free , I was thinking of maybe adding a file upload input in html then upload it to server using ajax and then include the file in tinymce editor. The problem is injecting image to tinymce, I don't know how to... Is there any way? 回答1: Ok, Micro$oft or someone else needs to really do something about this, in the mean time here is the result of hours of debugging: This solution uses direct upload function

return bool from asp.net mvc actionresult

假如想象 提交于 2021-02-17 09:16:28
问题 I submitted a form via jquery, but I need the ActionResult to return true or false. this is the code which for the controller method: [HttpPost] public ActionResult SetSchedule(FormCollection collection) { try { // TODO: Add update logic here return true; //cannot convert bool to actionresult } catch { return false; //cannot convert bool to actionresult } } How would I design my JQuery call to pass that form data and also check if the return value is true or false. How do I edit the code

return bool from asp.net mvc actionresult

烈酒焚心 提交于 2021-02-17 09:12:13
问题 I submitted a form via jquery, but I need the ActionResult to return true or false. this is the code which for the controller method: [HttpPost] public ActionResult SetSchedule(FormCollection collection) { try { // TODO: Add update logic here return true; //cannot convert bool to actionresult } catch { return false; //cannot convert bool to actionresult } } How would I design my JQuery call to pass that form data and also check if the return value is true or false. How do I edit the code

How to configure startup.cs based on solution configuration and not environment variable?

故事扮演 提交于 2021-02-17 03:35:57
问题 One way of configuring startup.cs is to check the environment based on an environmental variable, and run the appropriate code within the Configure method: // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); // The default HSTS value is 30 days. You may want to

Using EF DbContext with mysql and sql in the same project

ぐ巨炮叔叔 提交于 2021-02-16 15:23:56
问题 I'm working on an ASP.net MVC project using EF in combination with MySql. Now this works just fine on its own but I also want to reference another class library that uses EF with SQL. When I reference the library EF seems to get confused on what provider to use for each DbContext. On my MySql DbContext I have the following attribute in order to tell EF this DbContext should be handled by the MySql provider: [DbConfigurationType(typeof(MySql.Data.Entity.MySqlEFConfiguration))] Now on the SQL