Asked  9 Months ago    Answers:  5   Viewed   17 times

i have an asp.net application which as desired feature, users would like to be able to take a screenshot. while i know this can be simulated, it would be really great to have a way to take a url (or the current rendered page), and turn it into an image which can be stored on the server.

is this crazy? is there a way to do it? if so, any references?

 Answers

5

i can tell you right now that there is no way to do it from inside the browser, nor should there be. imagine that your page embeds gmail in an iframe. you could then steal a screenshot of the person's gmail inbox!

this could be made safe by having the browser "black out" all iframes and embeds that would violate cross-domain restrictions.

you could certainly write an extension to do this, but be aware of the security considerations outlined above.

update: you can use a canvas utility function to get a screenshot of a page on the same origin as your code. there's even a lib to allow you to do this: http://experiments.hertzen.com/jsfeedback/

you can find other possible answers here: using html5/canvas/javascript to take screenshots

Thursday, October 14, 2021
 
Thibel
 
2

in android 2.2 you could do the following.

create an xml drawable such as /res/drawable/textlines.xml and assign this as a textview's background property.

<textview
android:text="my text with lines above and below"
android:background="@drawable/textlines"
/>

/res/drawable/textlines.xml

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
    <item>
      <shape 
        android:shape="rectangle">
            <stroke android:width="1dp" android:color="#ff000000" />
            <solid android:color="#ffdddddd" />

        </shape>
   </item>

   <item android:top="1dp" android:bottom="1dp"> 
      <shape 
        android:shape="rectangle">
            <stroke android:width="1dp" android:color="#ffdddddd" />
            <solid android:color="#00000000" />
        </shape>
   </item>

</layer-list>

the down side to this is that you have to specify an opaque background colour, as transparencies won't work. (at least i thought they did but i was mistaken). in the above example you can see that the solid colour of the first shape #ffdddddd is copied in the 2nd shapes stroke colour.

Tuesday, June 1, 2021
 
ajaybc
 
2

perhaps using the google gson library you can deserialise the array to a typed collection of objects, and then using collections perform a sort.

look at 6th line in on the following link.. looks a bit messy but might be quickest way..

http://sites.google.com/site/gson/gson-user-guide#toc-collections-examples

Saturday, August 7, 2021
 
redrom
 
3

you can use attributes to implement a feature in an aspect-oriented way. action methods that you want to surround with your functionality then only need to be decorated with your attribute:

[customlogger]
public actionresult index()
{
    // doing something here ...
    return view();
}

you can either decorate a single action method with an attribute, an entire controller, or even apply the attribute globally through asp.net mvc's globalfiltercollection.

here's how you'd declare your attribute:

public class customloggerattribute : actionfilterattribute
{
    public override void onactionexecuted(actionexecutedcontext filtercontext)
    {
        base.onactionexecuted(filtercontext);

        // here goes your logic
    }

    // ...
}

the actionfilterattribute class allows you to override a couple of methods so you can hook into asp.net mvc's action execution pipeline:

  • onactionexecuting
  • onactionexecuted
  • onresultexecuting
  • onresultexecuted

you can access request variables through the parameters (like actionexecutedcontext) that are passed to the above methods.

Friday, September 10, 2021
 
5

same issue was resolved when mvcrazorcompileonpublish was added to .csproj file.

give it a try.

<mvcrazorcompileonpublish>true</mvcrazorcompileonpublish>
<mvcrazorexcluderefassembliesfrompublish>false</mvcrazorexcluderefassembliesfrompublish>
Saturday, November 6, 2021
 
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :  
Share