Exemplo n.º 1
0
        // POST: /launcher/hostbinary
        public async Task <IActionResult> HostBinary(HostedFile file)
        {
            try
            {
                BinaryLauncher launcher = await _context.GenerateBinaryLauncher();

                HttpListener listener = await _context.GetHttpListener(file.ListenerId);

                file = await _context.CreateHostedFile(listener.Id, file);

                launcher = await _context.GenerateBinaryHostedLauncher(file);

                return(RedirectToAction(nameof(Create), new { id = launcher.Name }));
            }
            catch (Exception e) when(e is ControllerNotFoundException || e is ControllerBadRequestException || e is ControllerUnauthorizedException)
            {
                ModelState.AddModelError(string.Empty, e.Message);
                return(RedirectToAction(nameof(Create), new { id = "Binary" }));
            }
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Create(HostedFile file)
        {
            try
            {
                HostedFile createdFile = await _context.CreateHostedFile(file);

                return(RedirectToAction("Interact", "Listener", new { Id = createdFile.Id }));
            }
            catch (Exception e) when(e is ControllerNotFoundException || e is ControllerBadRequestException || e is ControllerUnauthorizedException)
            {
                ModelState.AddModelError(string.Empty, e.Message);
                return(View(new HostedFile {
                    ListenerId = file.ListenerId
                }));
            }
        }
Exemplo n.º 3
0
        public async Task <ActionResult <HostedFile> > CreateHostedFile(int id, [FromBody] HostedFile file)
        {
            try
            {
                HostedFile hostedFile = await _context.CreateHostedFile(file);

                return(CreatedAtRoute(nameof(GetHostedFile), new { id = id, hfid = file.Id }, hostedFile));
            }
            catch (ControllerNotFoundException e)
            {
                return(NotFound(e.Message));
            }
            catch (ControllerBadRequestException e)
            {
                return(BadRequest(e.Message));
            }
        }