103 articles ASP.NET MVC Page 8 / 11

ASP MVC Create/Export Excel using NPOI

Pemrosesan excel menggunakan Excel.Interop di ASP sepertinya bermasalah. 1. Perlu meng-install excel di server 2. Ada potensi error “Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 8000401a The server process could not be started because the configured identity is incorrect. Check the username and password. (Exception from…

ASP MVC Composite Key

Contoh composite key adalah tabel plan_account. Id unik plan_account adalah kombinasi plan_id dan account_id. Jika tidak ditangani, composite key akan menghasilkan error pada ASP MVC. Business.Entities.plan_account: : EntityType ‘plan_account’ has no key defined. Define the key for this EntityType. plan_account: EntityType: EntitySet ‘plan_account’ is based on type ‘plan_account’ that has no keys defined. Solusinya adalah…

ASP.NET Interop.Excel Import Failed Not Enough Memory

Sewaktu men-deploy aplikasi di server CSS Pertamina, muncul masalah di fitur export excel. Microsoft Office Excel cannot open or save any more documents because there is not enough available memory or disk space. Ada solusi dari web ini yang berhasil. I know this is an old thread but I wanted to share what worked for…

ASP.NET Fetch Image in Excel File

Menggunakan Interop.Excel ternyata mengalami kendala ketika akan mengambil image dari file excel. Banyak website menyarankan menggunakan Interop.Excel dan Clipboard. Solusi tersebut sepertinya berfungsi untuk desktop app, tapi tidak berfungsi di web app. Solusi yang saat ini saya temukan adalah mengganti library dari Interop.Excel menjadi NPOI. NPOI bisa di download menggunakan NuGET. Contoh kode untuk mengambil…

ASP MVC Form Model Binding to Non-Sequential List

[code language=”html”] <form method="post" action="/Home/Create"> <input type="hidden" name="products.Index" value="cold" /> <input type="text" name="products[cold].Name" value="Beer" /> <input type="text" name="products[cold].Price" value="7.32" /> <input type="hidden" name="products.Index" value="123" /> <input type="text" name="products[123].Name" value="Chips" /> <input type="text" name="products[123].Price" value="2.23" /> <input type="hidden" name="products.Index" value="caliente" /> <input type="text" name="products[caliente].Name" value="Salsa" /> <input type="text" name="products[caliente].Price" value="1.23" /> <input type="submit" /> </form> [/code]…

ASP.NET MVC Default Route to Area

[Warning] Mengakibatkan masalah ketika memanggil @Url.Action tapi tidak ada area. Disarankan default page jangan di dalam area. Masalah ketika default page di dalam area. Controller masuk, tapi mencari view di luar area. RouteConfig.cs [code language=”csharp”] public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( "Default", "{controller}/{action}/{id}", new { controller = "Dashboard", action = "Index", area =…

ADO.NET Entity Framework Many-to-Many

Jika ada tabel many-to-many, dengan tabel perantara yang tidak memiliki id, perlu penanganan khusus pada DbContext. Contoh penanganan sbb: [code language=”csharp”] public class SchoolContext : DbContext { public DbSet<Course> Courses { get; set; } public DbSet<Person> People { get; set; } public SchoolContext() : base("MyDb") { } protected override void OnModelCreating(DbModelBuilder modelBuilder) { modelBuilder.Entity<Course>(). HasMany(c…