Skip to content
TheChatArchiveThe Chat Archive
o4-mini-2025-04-16· OpenAIHugging Face LMArena Human Preference 140K

Write me a simple app with vuejs frontend and c# backend

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Mistralmistral-medium-2505’s answer.
  1. User

    Write me a simple app with vuejs frontend and c# backend

  2. Assistant

    Here’s a minimal “Todo”‐style app that uses

    1. a C# /.NET minimal‐API backend
    2. a Vue 3 (Vite) frontend

    It supports CRUD on “todos.”


    1) Backend (C#, .NET 7 Minimal API)

    1. Create a new Web API project:
      dotnet new web -o TodoApi
      cd TodoApi
      
    2. Edit Program.cs to the following:
    using Microsoft.AspNetCore.Builder;
    using Microsoft.AspNetCore.Http.Json;
    using Microsoft.Extensions.DependencyInjection;
    using System.Collections.Concurrent;
    
    var builder = WebApplication.CreateBuilder(args);
    
    // Enable CORS for local dev
    builder.Services.AddCors(options =>
      options.AddDefaultPolicy(p => 
        p.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader()
      )
    );
    
    // Use simple in‐memory store
    var todos = new ConcurrentDictionary<int, TodoItem>();
    var nextId = 1;
    
    builder.Services.Configure<JsonOptions>(opts =>
        opts.SerializerOptions.PropertyNamingPolicy = null
    );
    
    var app = builder.Build();
    app.UseCors();
    
    // Map endpoints
    app.MapGet("/api/todos", () => todos.Values);
    
    app.MapGet("/api/todos/{id:int}", (int id) =>
        todos.TryGetValue(id, out var todo) ? Results.Ok(todo) : Results.NotFound()
    );
    
    app.MapPost("/api/todos", (TodoItem input) =>
    {
        var id = nextId++;
        input.Id = id;
        todos[id] = input;
        return Results.Created($"/api/todos/{id}", input);
    });
    
    app.MapPut("/api/todos/{id:int}", (int id, TodoItem update) =>
    {
        if (!todos.ContainsKey(id)) return Results.NotFound();
        update.Id = id;
        todos[id] = update;
        return Results.NoContent();
    });
    
    app.MapDelete("/api/todos/{id:int}", (int id) =>
        todos.TryRemove(id, out _)
          ? Results.NoContent()
          : Results.NotFound()
    );
    
    app.Run();
    
    public record TodoItem
    {
        public int Id { get; set; }
        public string Title { get; set; } = "";
        public bool Done { get; set; }
    }
    
    1. Run it:
      dotnet run
      
      By default it listens on http://localhost:5000.

    2) Frontend (Vue 3 + Vite)

    1. Scaffold with Vite:
      npm init vite@latest todo-vue -- –template vue
      cd todo-vue
      npm install
      
    2. Install Axios for HTTP:
      npm install axios
      
    3. Replace src/App.vue with:
    <template>
      <div class="app">
        <h1>Vue 3 + .NET Todo</h1>
        <form @submit.prevent="addTodo">
          <input v-model="newTitle" placeholder="New todo…" />
          <button type="submit">Add</button>
        </form>
    
        <ul>
          <li v-for="t in todos" :key="t.id">
            <input type="checkbox" v-model="t.done" @change="update(t)" />
            <span :class="{ done: t.done }">{{ t.title }}</span>
            <button @click="remove(t.id)">✕</button>
          </li>
        </ul>
      </div>
    </template>
    
    <script setup>
    import { ref, onMounted } from 'vue'
    import axios from 'axios'
    
    const API = 'http://localhost:5000/api/todos'
    const todos = ref([])
    const newTitle = ref('')
    
    async function fetchTodos() {
      const { data } = await axios.get(API)
      todos.value = data
    }
    
    async function addTodo() {
      const title = newTitle.value.trim()
      if (!title) return
      await axios.post(API, { title, done: false })
      newTitle.value = ''
      fetchTodos()
    }
    
    async function update(todo) {
      await axios.put(`${API}/${todo.id}`, todo)
    }
    
    async function remove(id) {
      await axios.delete(`${API}/${id}`)
      fetchTodos()
    }
    
    onMounted(fetchTodos)
    </script>
    
    <style>
    .app { max-width: 400px; margin: auto; font-family: sans-serif; }
    .done { text-decoration: line-through; color: #888; }
    button { margin-left: 0.5em; }
    input[type="checkbox"] { margin-right: 0.5em; }
    </style>
    
    1. Run the frontend:
      npm run dev
      
      It’ll spin up at http://localhost:5173 by default.

    Now you have a super-simple full-stack Todo app:

    • The C# backend serves a JSON API.
    • The Vue 3 frontend consumes it via Axios.

    Feel free to expand (persist to a DB, add auth, style it, etc.). Enjoy! 🚀

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.