The next generation of the Teknik Services. Written in ASP.NET.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

51 lines
1.5 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.Mvc;
using Teknik.Areas.Stream.ViewModels;
using Teknik.Controllers;
namespace Teknik.Areas.Stream.Controllers
{
public class StreamController : DefaultController
{
[AllowAnonymous]
public ActionResult Index()
{
ViewBag.Title = "Teknikam";
StreamViewModel model = new StreamViewModel();
return View(model);
}
[HttpGet]
[AllowAnonymous]
public FileStreamResult ViewStream(int id)
{
try
{
if (Config.StreamConfig.Enabled)
{
if (id > 0 && id <= Config.StreamConfig.Sources.Count)
{
// ID is valid, so let's get the stream
string source = Config.StreamConfig.Sources[id - 1];
//Create a WebRequest to get the file
HttpWebRequest fileReq = (HttpWebRequest)HttpWebRequest.Create(source);
//Create a response for this request
HttpWebResponse fileResp = (HttpWebResponse)fileReq.GetResponse();
return File(fileResp.GetResponseStream(), fileResp.ContentType);
}
}
}
catch (Exception)
{
}
return null;
}
}
}