Quantcast
Channel: THWACK: All Content - Orion SDK
Viewing all articles
Browse latest Browse all 2677

c# ASP.NET MVC Razor Web App Thoughts

$
0
0

Overview

Over the past month or so I have been tasked with building web app that would push configuration changes to multiple devices in a multi-stage approach, track the user making the changes and enforce a strict process on these changes.

 

I figured I would share some of the code I put together to make this all happen and give some incites on the issues I encountered and how I overcame these.  I would like to note that this was my first ASP.NET application so by no means is it perfect so please provide input on ways to improve.

 

Requirements

  • Push scripts and capture execution
  • Send emails
  • Multi-stage Execution
  • AAA - Authentication, Authorization, Accounting - integrate with SolarWinds

 

 

Architecture

To integrate as much as possible within SolarWinds it was decided to develop in c# and place the ASP.NET application onto the SolarWinds Orion server.  I was able to install the final application as a sub application under the SolarWinds IIS Application allowing use of the same base website and SSL certificate.  This also allowed for tighter integration of Authentication.

 

The semi-modern MVC (Model, View, Controller)  web app architecture was leveraged as it is well documented.   ASP.NET Razor was used to allow server side execution of inline c# code within the web pages (cshtml).   Wrapper classes where created around defined SolarWinds API and Microsoft .NET classes to capture and log interactions and errors.   The "Shared" view for web pages provided a wrapper to all web page "body" sections providing a consistent header/menu bar at top of all pages.

 

Other then the SolarWinds SDK/API and bootstrap css all other packages/references where standard Microsoft packages/references.  Bootstrap was chosen due to it’s prevalence and in depth documentation.

 

Authentication is provided by enabling “Windows Account Login” which turns off form based authentication and enables Basic Web Authentication within IIS.  Authorization is provide by leveraging the SolarWinds authorization settings within the Orion.Accounts SWIS Object and altering the web pages accordingly.  Accounting is provided by logging to a custom database table. 

 

Future

Planned future changes include adding Javascript to web pages, migrate entirely to html5 webpages (more interactive look and feel) and  possibly migrating to SolarWinds css. 

 

Lessons Learned

  • How to integrate ASP.NET applications using <clear /><remove /> tags in child web.config lists and <location path="." inheritInChildApplications="false"> for XML sections in parent web.config files
  • How to encrypt sections of web.config file:
  • model objects are not preserved while transitioning pages as HTTP is stateless - must use forms to pass data
  • Re-use web pages as much as possible (i.e. Each stage uses same web pages)

 

Example code

(Follow the NameSpaces)

model_p1.clean.cs          - Data (Main model class)

model_p2.clean.cs          - SWISClient wrapper classes (leveraged within the Model - note I use one model class across all views)

model_p3.clean.cs          - Email wrapper classes (leveraged within the Model - note I use one model class across all views)


Viewing all articles
Browse latest Browse all 2677

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>