From a556642489b15e910e253bee2c9c32c9e91387f8 Mon Sep 17 00:00:00 2001 From: "jason.zhu" Date: Thu, 10 Jun 2021 12:58:37 +1000 Subject: [PATCH] Finished 'Controllers in ASP.NET MVC Application' --- FirstMVCDemo/App_Start/RouteConfig.cs | 23 +++ FirstMVCDemo/Controllers/HomeController.cs | 17 +++ FirstMVCDemo/FirstMVCDemo.csproj | 155 +++++++++++++++++++++ FirstMVCDemo/FirstMVCDemo.sln | 25 ++++ FirstMVCDemo/Global.asax | 1 + FirstMVCDemo/Global.asax.cs | 18 +++ FirstMVCDemo/Properties/AssemblyInfo.cs | 35 +++++ FirstMVCDemo/Views/web.config | 42 ++++++ FirstMVCDemo/Web.Debug.config | 30 ++++ FirstMVCDemo/Web.Release.config | 31 +++++ FirstMVCDemo/Web.config | 43 ++++++ FirstMVCDemo/packages.config | 8 ++ 12 files changed, 428 insertions(+) create mode 100644 FirstMVCDemo/App_Start/RouteConfig.cs create mode 100644 FirstMVCDemo/Controllers/HomeController.cs create mode 100644 FirstMVCDemo/FirstMVCDemo.csproj create mode 100644 FirstMVCDemo/FirstMVCDemo.sln create mode 100644 FirstMVCDemo/Global.asax create mode 100644 FirstMVCDemo/Global.asax.cs create mode 100644 FirstMVCDemo/Properties/AssemblyInfo.cs create mode 100644 FirstMVCDemo/Views/web.config create mode 100644 FirstMVCDemo/Web.Debug.config create mode 100644 FirstMVCDemo/Web.Release.config create mode 100644 FirstMVCDemo/Web.config create mode 100644 FirstMVCDemo/packages.config diff --git a/FirstMVCDemo/App_Start/RouteConfig.cs b/FirstMVCDemo/App_Start/RouteConfig.cs new file mode 100644 index 0000000..3e09288 --- /dev/null +++ b/FirstMVCDemo/App_Start/RouteConfig.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.Mvc; +using System.Web.Routing; + +namespace FirstMVCDemo +{ + public class RouteConfig + { + public static void RegisterRoutes(RouteCollection routes) + { + routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); + + routes.MapRoute( + name: "Default", + url: "{controller}/{action}/{id}", + defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } + ); + } + } +} diff --git a/FirstMVCDemo/Controllers/HomeController.cs b/FirstMVCDemo/Controllers/HomeController.cs new file mode 100644 index 0000000..94c28dc --- /dev/null +++ b/FirstMVCDemo/Controllers/HomeController.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.Mvc; + +namespace FirstMVCDemo.Controllers +{ + public class HomeController : Controller + { + // GET: Home + public string Index(string id, string name) + { + return "Id = " + id + ", Name = " + Request.QueryString["name"]; + } + } +} \ No newline at end of file diff --git a/FirstMVCDemo/FirstMVCDemo.csproj b/FirstMVCDemo/FirstMVCDemo.csproj new file mode 100644 index 0000000..1aec46e --- /dev/null +++ b/FirstMVCDemo/FirstMVCDemo.csproj @@ -0,0 +1,155 @@ + + + + + Debug + AnyCPU + + + 2.0 + {EB95F77A-8292-4A28-ACFB-35D2A9E1A9FE} + {349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} + Library + Properties + FirstMVCDemo + FirstMVCDemo + v4.8 + true + + + + + + + + + + + true + full + false + bin\ + DEBUG;TRACE + prompt + 4 + + + true + pdbonly + true + bin\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + + + packages\Microsoft.AspNet.Razor.3.2.7\lib\net45\System.Web.Razor.dll + + + packages\Microsoft.AspNet.Webpages.3.2.7\lib\net45\System.Web.Webpages.dll + + + packages\Microsoft.AspNet.Webpages.3.2.7\lib\net45\System.Web.Webpages.Deployment.dll + + + packages\Microsoft.AspNet.Webpages.3.2.7\lib\net45\System.Web.Webpages.Razor.dll + + + packages\Microsoft.AspNet.Webpages.3.2.7\lib\net45\System.Web.Helpers.dll + + + packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll + + + packages\Microsoft.AspNet.Mvc.5.2.7\lib\net45\System.Web.Mvc.dll + + + packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\lib\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll + + + + + + + + + + + Global.asax + + + + + + + + Web.config + + + Web.config + + + + + + + + + 10.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + + + + + + True + True + 59540 + / + http://localhost:59540/ + False + False + + + False + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + \ No newline at end of file diff --git a/FirstMVCDemo/FirstMVCDemo.sln b/FirstMVCDemo/FirstMVCDemo.sln new file mode 100644 index 0000000..43f1de8 --- /dev/null +++ b/FirstMVCDemo/FirstMVCDemo.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30907.101 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FirstMVCDemo", "FirstMVCDemo.csproj", "{EB95F77A-8292-4A28-ACFB-35D2A9E1A9FE}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {EB95F77A-8292-4A28-ACFB-35D2A9E1A9FE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EB95F77A-8292-4A28-ACFB-35D2A9E1A9FE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EB95F77A-8292-4A28-ACFB-35D2A9E1A9FE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EB95F77A-8292-4A28-ACFB-35D2A9E1A9FE}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {7EBF9946-83CE-4AA6-9569-F48F1370A995} + EndGlobalSection +EndGlobal diff --git a/FirstMVCDemo/Global.asax b/FirstMVCDemo/Global.asax new file mode 100644 index 0000000..cd2a315 --- /dev/null +++ b/FirstMVCDemo/Global.asax @@ -0,0 +1 @@ +<%@ Application Codebehind="Global.asax.cs" Inherits="FirstMVCDemo.MvcApplication" Language="C#" %> diff --git a/FirstMVCDemo/Global.asax.cs b/FirstMVCDemo/Global.asax.cs new file mode 100644 index 0000000..90ba47c --- /dev/null +++ b/FirstMVCDemo/Global.asax.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.Mvc; +using System.Web.Routing; + +namespace FirstMVCDemo +{ + public class MvcApplication : System.Web.HttpApplication + { + protected void Application_Start() + { + AreaRegistration.RegisterAllAreas(); + RouteConfig.RegisterRoutes(RouteTable.Routes); + } + } +} diff --git a/FirstMVCDemo/Properties/AssemblyInfo.cs b/FirstMVCDemo/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..fa010c1 --- /dev/null +++ b/FirstMVCDemo/Properties/AssemblyInfo.cs @@ -0,0 +1,35 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("FirstMVCDemo")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("FirstMVCDemo")] +[assembly: AssemblyCopyright("Copyright © 2021")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("eb95f77a-8292-4a28-acfb-35d2a9e1a9fe")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/FirstMVCDemo/Views/web.config b/FirstMVCDemo/Views/web.config new file mode 100644 index 0000000..a9988ad --- /dev/null +++ b/FirstMVCDemo/Views/web.config @@ -0,0 +1,42 @@ + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/FirstMVCDemo/Web.Debug.config b/FirstMVCDemo/Web.Debug.config new file mode 100644 index 0000000..fae9cfe --- /dev/null +++ b/FirstMVCDemo/Web.Debug.config @@ -0,0 +1,30 @@ + + + + + + + + + + \ No newline at end of file diff --git a/FirstMVCDemo/Web.Release.config b/FirstMVCDemo/Web.Release.config new file mode 100644 index 0000000..da6e960 --- /dev/null +++ b/FirstMVCDemo/Web.Release.config @@ -0,0 +1,31 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/FirstMVCDemo/Web.config b/FirstMVCDemo/Web.config new file mode 100644 index 0000000..417fbf9 --- /dev/null +++ b/FirstMVCDemo/Web.config @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/FirstMVCDemo/packages.config b/FirstMVCDemo/packages.config new file mode 100644 index 0000000..deaab0c --- /dev/null +++ b/FirstMVCDemo/packages.config @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file